Class: ActsAsScriptural::AbbreviationLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_scriptural/abbreviation_lookup.rb

Instance Method Summary collapse

Constructor Details

#initializeAbbreviationLookup

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

#bibleObject



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