Class: Thepub::Epub::NCX::NavMap
- Defined in:
- lib/thepub/epub/ncx.rb
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
Attributes inherited from NavPoint
#play_order, #points, #src, #title
Instance Method Summary collapse
- #calc_depth_and_play_order ⇒ Object
-
#initialize ⇒ NavMap
constructor
A new instance of NavMap.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize ⇒ NavMap
Returns a new instance of NavMap.
109 110 111 112 |
# File 'lib/thepub/epub/ncx.rb', line 109 def initialize super(nil, nil) @depth = 1 end |
Instance Attribute Details
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
114 115 116 |
# File 'lib/thepub/epub/ncx.rb', line 114 def depth @depth end |
Instance Method Details
#calc_depth_and_play_order ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/thepub/epub/ncx.rb', line 116 def calc_depth_and_play_order play_order = 0 l = lambda do |points, depth| @depth = depth if depth > @depth points.each do |pt| pt.play_order = (play_order += 1) l.call(pt.points, depth + 1) unless pt.points.empty? end end l.call(@points, @depth = 1) end |
#to_xml(builder) ⇒ Object
128 129 130 131 132 |
# File 'lib/thepub/epub/ncx.rb', line 128 def to_xml(builder) builder.navMap do @points.each { |point| point.to_xml(builder) } end end |