Class: ReVIEW::TOCParser::Chapter

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

Instance Attribute Summary collapse

Attributes inherited from Section

#label, #level

Attributes inherited from Node

#children

Instance Method Summary collapse

Methods inherited from Section

#estimated_lines, #yield_section

Methods inherited from Node

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

Constructor Details

#initialize(label, chap) ⇒ Chapter

Returns a new instance of Chapter.



202
203
204
205
206
207
208
209
210
# File 'lib/review/tocparser.rb', line 202

def initialize(label, chap)
  super(1, label, chap.path)
  @chapter = chap
  @chapter_id = chap.id
  @path = chap.path
  @page_metric = chap.book.page_metric
  @volume = nil
  @number = nil
end

Instance Attribute Details

#chapter_idObject (readonly)

Returns the value of attribute chapter_id.



218
219
220
# File 'lib/review/tocparser.rb', line 218

def chapter_id
  @chapter_id
end

#numberObject

Returns the value of attribute number.



212
213
214
# File 'lib/review/tocparser.rb', line 212

def number
  @number
end

Instance Method Details

#chapter?Boolean

Returns:

  • (Boolean)


214
215
216
# File 'lib/review/tocparser.rb', line 214

def chapter?
  true
end

#inspectObject



227
228
229
# File 'lib/review/tocparser.rb', line 227

def inspect
  "#<#{self.class} #{@filename}>"
end

#volumeObject



220
221
222
223
224
225
# File 'lib/review/tocparser.rb', line 220

def volume
  return @volume if @volume
  @volume = @chapter.volume
  @volume.lines = estimated_lines
  @volume
end