Class: Repub::Epub::Toc::NavMap::NavPoint

Inherits:
Struct
  • Object
show all
Defined in:
lib/repub/epub/toc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, src) ⇒ NavPoint

Returns a new instance of NavPoint.



79
80
81
82
83
84
# File 'lib/repub/epub/toc.rb', line 79

def initialize(title, src)
  super
  @@last_play_order = 0
  @play_order = 0
  @child_points = []
end

Instance Attribute Details

#srcObject

Returns the value of attribute src

Returns:

  • (Object)

    the current value of src



74
75
76
# File 'lib/repub/epub/toc.rb', line 74

def src
  @src
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



74
75
76
# File 'lib/repub/epub/toc.rb', line 74

def title
  @title
end

Instance Method Details

#add_nav_point(title, src) ⇒ Object



86
87
88
89
90
# File 'lib/repub/epub/toc.rb', line 86

def add_nav_point(title, src)
  nav_point = NavPoint.new(title, src)
  @child_points << nav_point
  nav_point
end

#calc_depth_and_play_order(nav_map, depth) ⇒ Object



102
103
104
105
106
# File 'lib/repub/epub/toc.rb', line 102

def calc_depth_and_play_order(nav_map, depth)
  nav_map.depth = depth
  @play_order = @@last_play_order += 1
  @child_points.each { |child_point| child_point.calc_depth_and_play_order(nav_map, depth + 1) }
end

#to_xml(builder) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/repub/epub/toc.rb', line 92

def to_xml(builder)
  builder.navPoint :id => "navPoint-#{@play_order}", :playOrder => @play_order do
    builder.navLabel do
      builder.text self.title
    end
    builder.content :src => self.src
    @child_points.each { |child_point| child_point.to_xml(builder) }
  end
end