Class: Muplin::Outliner
- Inherits:
-
Object
- Object
- Muplin::Outliner
- Defined in:
- lib/muplin/outliner.rb
Instance Method Summary collapse
- #clear_outlines ⇒ Object
- #define_outline(outlines, parent = nil) ⇒ Object
-
#initialize(filename) ⇒ Outliner
constructor
A new instance of Outliner.
- #render_file(filename) ⇒ Object
Constructor Details
#initialize(filename) ⇒ Outliner
Returns a new instance of Outliner.
3 4 5 |
# File 'lib/muplin/outliner.rb', line 3 def initialize(filename) @pdf = Prawn::Document.new(:template => filename) end |
Instance Method Details
#clear_outlines ⇒ Object
9 10 11 |
# File 'lib/muplin/outliner.rb', line 9 def clear_outlines @pdf.state.store.root.data[:Outlines] = nil end |
#define_outline(outlines, parent = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/muplin/outliner.rb', line 13 def define_outline(outlines, parent = nil) outlines.each do |item| if a_section?(item) add_section(item, parent) @last_label = item['label'] elsif sections?(item) define_outline(item, @last_label) else raise ArgumentError, item.inspect end end end |
#render_file(filename) ⇒ Object
26 27 28 |
# File 'lib/muplin/outliner.rb', line 26 def render_file(filename) @pdf.render_file(filename) end |