Class: ReVIEW::Book::ChapterIndex

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

Instance Method Summary collapse

Methods inherited from Index

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

Constructor Details

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

Instance Method Details

#display_string(id) ⇒ Object



94
95
96
# File 'lib/review/book/index.rb', line 94

def display_string(id)
  "#{number(id)}#{title(id)}"
end

#item_typeObject



75
76
77
# File 'lib/review/book/index.rb', line 75

def item_type
  'chapter'
end

#number(id) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/review/book/index.rb', line 79

def number(id)
  chapter = @index.fetch(id)
  if chapter.on_CHAPS?
    "#{I18n.t("chapter", chapter.number)}"
  elsif chapter.on_PREDEF?
    "#{chapter.number}"
  elsif chapter.on_POSTDEF?
    "#{I18n.t("appendix", chapter.number)}"
  end
end

#title(id) ⇒ Object



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

def title(id)
  @index.fetch(id).title
end