Class: ActsAsScriptural::AbbreviationLookup
- Inherits:
-
Object
- Object
- ActsAsScriptural::AbbreviationLookup
- Defined in:
- lib/acts_as_scriptural/abbreviation_lookup.rb
Instance Method Summary collapse
- #abbreviation_to_book(str) ⇒ Object
- #bible ⇒ Object
- #fullname(str) ⇒ Object
- #index_number(str) ⇒ Object
-
#initialize ⇒ AbbreviationLookup
constructor
A new instance of AbbreviationLookup.
Constructor Details
#initialize ⇒ AbbreviationLookup
Returns a new instance of AbbreviationLookup.
7 8 9 |
# File 'lib/acts_as_scriptural/abbreviation_lookup.rb', line 7 def initialize @hash = bible.book_names.abbrev.map{|k,v| [k.gsub(' ','').downcase,v]}.to_h end |
Instance Method Details
#abbreviation_to_book(str) ⇒ Object
23 24 25 |
# File 'lib/acts_as_scriptural/abbreviation_lookup.rb', line 23 def abbreviation_to_book(str) bible.namehash[fullname(str)] end |
#bible ⇒ Object
19 20 21 |
# File 'lib/acts_as_scriptural/abbreviation_lookup.rb', line 19 def bible @bible || ActsAsScriptural::Bible.new end |
#fullname(str) ⇒ Object
11 12 13 |
# File 'lib/acts_as_scriptural/abbreviation_lookup.rb', line 11 def fullname(str) @hash[str.gsub(' ','').downcase] end |
#index_number(str) ⇒ Object
15 16 17 |
# File 'lib/acts_as_scriptural/abbreviation_lookup.rb', line 15 def index_number(str) bible.namehash[fullname(str)].index end |