Class: ReVIEW::Book::ChapterIndex
Instance Method Summary
collapse
Methods inherited from Index
#[], #add_item, #each, #initialize, #key?, parse
Instance Method Details
#display_string(id) ⇒ Object
109
110
111
112
113
114
115
|
# File 'lib/review/book/index.rb', line 109
def display_string(id)
if number(id)
I18n.t('chapter_quote', [number(id), title(id)])
else
I18n.t('chapter_quote_without_number', title(id))
end
end
|
#item_type ⇒ Object
89
90
91
|
# File 'lib/review/book/index.rb', line 89
def item_type
'chapter'
end
|
#number(id) ⇒ Object
93
94
95
96
97
98
99
100
101
|
# File 'lib/review/book/index.rb', line 93
def number(id)
chapter_item = @index.fetch(id)
begin
chapter = chapter_item.content
chapter.format_number
rescue I18n.t('part', chapter.number)
end
end
|
#title(id) ⇒ Object
103
104
105
106
107
|
# File 'lib/review/book/index.rb', line 103
def title(id)
@index.fetch(id).content.title
rescue @index.fetch(id).content.name
end
|