Class: ReVIEW::TOCParser::Section

Inherits:
Node show all
Defined in:
lib/review/tocparser.rb

Direct Known Subclasses

Chapter

Instance Attribute Summary collapse

Attributes inherited from Node

#children

Instance Method Summary collapse

Methods inherited from Node

#add_child, #chapter?, #each_child, #each_node, #each_section, #each_section_with_index, #section_size

Constructor Details

#initialize(level, label, path = nil) ⇒ Section

Returns a new instance of Section.



175
176
177
178
179
180
# File 'lib/review/tocparser.rb', line 175

def initialize(level, label, path = nil)
  super()
  @level = level
  @label = label
  @filename = (path ? real_filename(path) : nil)
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



192
193
194
# File 'lib/review/tocparser.rb', line 192

def label
  @label
end

#levelObject (readonly)

Returns the value of attribute level.



191
192
193
# File 'lib/review/tocparser.rb', line 191

def level
  @level
end

Instance Method Details

#estimated_linesObject



194
195
196
# File 'lib/review/tocparser.rb', line 194

def estimated_lines
  @children.inject(0) {|sum, n| sum + n.estimated_lines }
end

#inspectObject



202
203
204
# File 'lib/review/tocparser.rb', line 202

def inspect
  "\#<#{self.class} level=#{@level} #{@label}>"
end

#yield_section {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



198
199
200
# File 'lib/review/tocparser.rb', line 198

def yield_section
  yield self
end