class Prawn::ManualBuilder::ExamplePackage

The Prawn::ManualBuilder::ExamplePackage class is a utility class to handle the packaging of individual examples within a hierarchy when building the manual.

Attributes

folder_name[R]
intro_block[R]
name[W]

Public Class Methods

new(folder_name) click to toggle source
# File lib/prawn/manual_builder/example_package.rb, line 12
def initialize(folder_name)
  @folder_name = folder_name
  @hierarchy = []
end

Public Instance Methods

example(filename, options={}) click to toggle source

Stores a new ExampleFile in the hierarchy

# File lib/prawn/manual_builder/example_package.rb, line 27
def example(filename, options={})
  @hierarchy << ExampleFile.new(self, "#{filename}.rb", options)
end
intro(&block) click to toggle source

Stores a block with code to be evaluated when rendering the package cover

# File lib/prawn/manual_builder/example_package.rb, line 33
def intro(&block)
  @intro_block = block
end
name() click to toggle source

Returns a human friendly version of the package name

# File lib/prawn/manual_builder/example_package.rb, line 39
def name
  @name ||= @folder_name.gsub("_", " ").capitalize
end
render(pdf) click to toggle source

Renders a cover page for the package to a pdf and iterates the examples hierarchy delegating the examples and sections to be rendered as well

# File lib/prawn/manual_builder/example_package.rb, line 46
def render(pdf)
  pdf.render_package_cover(self)
  
  @hierarchy.each do |node|
    node.render(pdf)
  end
end
section(name) { |s| ... } click to toggle source

Stores a new ExampleSection in the hierarchy and yields it to a block

# File lib/prawn/manual_builder/example_package.rb, line 19
def section(name)
  s = ExampleSection.new(self, name)
  yield s
  @hierarchy << s
end