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

#display_label, #estimated_lines, #yield_section

Methods inherited from Node

#add_child, #each_child, #each_node, #each_section, #each_section_with_index, #n_sections

Constructor Details

#initialize(label, id, path, page_metric) ⇒ Chapter

Returns a new instance of Chapter.



211
212
213
214
215
216
217
218
# File 'lib/review/tocparser.rb', line 211

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

Instance Attribute Details

#chapter_idObject (readonly)

Returns the value of attribute chapter_id.



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

def chapter_id
  @chapter_id
end

#numberObject

Returns the value of attribute number.



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

def number
  @number
end

Instance Method Details

#chapter?Boolean

Returns:

  • (Boolean)


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

def chapter?
  true
end

#inspectObject



237
238
239
# File 'lib/review/tocparser.rb', line 237

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

#volumeObject



228
229
230
231
232
233
234
235
# File 'lib/review/tocparser.rb', line 228

def volume
  return @volume if @volume
  return Book::Volume.dummy unless @path
  @volume = Book::Volume.count_file(@path)
  @volume.page_per_kbyte = @page_metric.page_per_kbyte
  @volume.lines = estimated_lines()
  @volume
end