Class: Epuber::BookspecGenerator::TocItem
- Inherits:
-
Object
- Object
- Epuber::BookspecGenerator::TocItem
- Defined in:
- lib/epuber/from_file/bookspec_generator.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attribs ⇒ Object
-
#initialize(href, title = nil, landmarks = [], children = []) ⇒ TocItem
constructor
A new instance of TocItem.
- #inspect ⇒ Object
- #to_s(level = 0) ⇒ Object
Constructor Details
#initialize(href, title = nil, landmarks = [], children = []) ⇒ TocItem
Returns a new instance of TocItem.
24 25 26 27 28 29 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 24 def initialize(href, title = nil, landmarks = [], children = []) @href = href @title = title @landmarks = landmarks @children = children end |
Instance Attribute Details
#children ⇒ Array<TocItem>
18 19 20 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 18 def children @children end |
#href ⇒ String
10 11 12 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 10 def href @href end |
#landmarks ⇒ Array<Symbol>
22 23 24 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 22 def landmarks @landmarks end |
#title ⇒ String?
14 15 16 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 14 def title @title end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 35 def ==(other) other.is_a?(TocItem) && href == other.href && title == other.title && landmarks == other.landmarks && children == other.children end |
#attribs ⇒ Object
31 32 33 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 31 def attribs [href.inspect, title&.inspect, *landmarks.map(&:inspect)].compact.join(', ') end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 49 def inspect %(#<#{self.class.name} #{self}>) end |
#to_s(level = 0) ⇒ Object
43 44 45 46 47 |
# File 'lib/epuber/from_file/bookspec_generator.rb', line 43 def to_s(level = 0) indent = ' ' * level children_str = children.map { |c| c.to_s(level + 2) }.join("\n") %(#{indent}#{href.inspect} #{title.inspect} #{landmarks.inspect}\n#{children_str}) end |