Class: BibleReferenceParser::BibleMetadata
- Inherits:
-
Object
- Object
- BibleReferenceParser::BibleMetadata
- Defined in:
- lib/bible_reference_parser/metadata/bible_metadata.rb
Overview
This class encapsulates the metadata about a book’s name and short name. It also holds info on the number of verses in each chapter. See metadata.yml for more details.
Class Attribute Summary collapse
-
.metadata ⇒ Object
readonly
The metadata contents loaded from the yaml file.
Class Method Summary collapse
-
.[](book_name) ⇒ Object
Access metadata information for the specified book_name.
Class Attribute Details
.metadata ⇒ Object (readonly)
The metadata contents loaded from the yaml file.
10 11 12 |
# File 'lib/bible_reference_parser/metadata/bible_metadata.rb', line 10 def @metadata end |
Class Method Details
.[](book_name) ⇒ Object
Access metadata information for the specified book_name. book_name can either be the full name, or one of the book’s abbreviations. For the names and abbreviations recognized, see the metadata.yml file.
The metadata.yml file indexes book names in lowercase without spaces. The parameter passed in is converted to this format automatically.
Examples:
BibleMetadata["Genesis"]
BibleMetadata["gen"]
BibleMetadata["rev."]
The returned object is a hash. Example:
{
"name" => "Genesis",
"short" => "Gen.",
"chapter_info" => [31,25,24,26,32,22,24,22,29,32,32...]
}
If the book isn’t found, “nil” is returned.
33 34 35 36 37 |
# File 'lib/bible_reference_parser/metadata/bible_metadata.rb', line 33 def [](book_name) # make lowercase and strip out any spaces or periods index = book_name.downcase.gsub(/\s*\.*/, "") [index] end |