Class: Prawn::ManualBuilder::ExampleSection
- Inherits:
-
Object
- Object
- Prawn::ManualBuilder::ExampleSection
- 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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#example(filename, options = {}) ⇒ Object
Stores a new ExampleFile in the examples list.
-
#folder_name ⇒ Object
Returns this example’s package original folder name.
-
#initialize(package, name) ⇒ ExampleSection
constructor
A new instance of ExampleSection.
-
#package_name ⇒ Object
Returns the human friendly version of this section’s package name.
-
#render(pdf) ⇒ Object
Renders the section to a pdf and iterates the examples list delegating the examples to be rendered as well.
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
#name ⇒ Object (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, ={}) @examples << ExampleFile.new(self, "#{filename}.rb", ) end |
#folder_name ⇒ Object
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_name ⇒ Object
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 |