Class: ReVIEW::Book::ChapterIndex

Inherits:
Index show all
Defined in:
lib/review/book/index.rb

Instance Method Summary collapse

Methods inherited from Index

#[], #each, #initialize, item_class, #key?, parse

Constructor Details

This class inherits a constructor from ReVIEW::Book::Index

Instance Method Details

#display_string(id) ⇒ Object



102
103
104
# File 'lib/review/book/index.rb', line 102

def display_string(id)
  "#{number(id)}#{I18n.t('chapter_quote', title(id))}"
end

#item_typeObject



85
86
87
# File 'lib/review/book/index.rb', line 85

def item_type
  'chapter'
end

#number(id) ⇒ Object



89
90
91
92
93
94
# File 'lib/review/book/index.rb', line 89

def number(id)
  chapter = @index.fetch(id)
  chapter.format_number
rescue # part
  I18n.t('part', chapter.number)
end

#title(id) ⇒ Object



96
97
98
99
100
# File 'lib/review/book/index.rb', line 96

def title(id)
  @index.fetch(id).title
rescue # non-file part
  @index.fetch(id).name
end