Class: Muplin::Outliner

Inherits:
Object
  • Object
show all
Defined in:
lib/muplin/outliner.rb

Instance Method Summary collapse

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_outlinesObject



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