Class: Prawn::ManualBuilder::ExampleSection

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/manual_builder/example_section.rb

Overview

The Prawn::ManualBuilder::ExampleSection class is a utility class to handle sections of related examples within an ExamplePackage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package, name) ⇒ ExampleSection

Returns a new instance of ExampleSection.



11
12
13
14
15
# File 'lib/prawn/manual_builder/example_section.rb', line 11

def initialize(package, name)
  @package  = package
  @name     = name
  @examples = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/prawn/manual_builder/example_section.rb', line 9

def name
  @name
end

Instance Method Details

#example(filename, options = {}) ⇒ Object

Stores a new ExampleFile in the examples list



19
20
21
# File 'lib/prawn/manual_builder/example_section.rb', line 19

def example(filename, options={})
  @examples << ExampleFile.new(self, "#{filename}.rb", options)
end

#folder_nameObject

Returns this example’s package original folder name



25
26
27
# File 'lib/prawn/manual_builder/example_section.rb', line 25

def folder_name
  @package.folder_name
end

#package_nameObject

Returns the human friendly version of this section’s package name



31
32
33
# File 'lib/prawn/manual_builder/example_section.rb', line 31

def package_name
  @package.name
end

#render(pdf) ⇒ Object

Renders the section to a pdf and iterates the examples list delegating the examples to be rendered as well



38
39
40
41
42
43
44
# File 'lib/prawn/manual_builder/example_section.rb', line 38

def render(pdf)
  pdf.render_section(self)
  
  @examples.each do |example|
    example.render(pdf)
  end
end