module StandardWorks
Main Module
Extension for Abbreviations
Main Module
Constants
- LOCATION
- OPTIONS
- VERSION
Public Class Methods
abrv()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/standard_works/abbreviations.rb, line 10 def self.abrv { # This one Is Opposite due to how the references are stored 'Doctrine and Covenants' => 'D&C', # POG 'Abr.' => 'Abraham', 'JS-M' => 'Joseph Smith—Matthew', 'JS-H' => 'Joseph Smith—History', 'A of F' => 'Articles of Faith', # Others 'Gen.' => 'Genesis', 'Ex.' => 'Exodus', 'Lev.' => 'Leviticus', 'Num.' => 'Numbers', 'Deut.' => 'Deuteronomy', 'Josh.' => 'Joshua', 'Judg.' => 'Judges', '1 Sam.' => '1 Samuel', '2 Sam.' => '2 Samuel', '1 Kgs.' => '1 Kings', '2 Kgs.' => '2 Kings', '1 Chr.' => '1 Chronicles', '2 Chr.' => '2 Chronicles', 'Neh.' => 'Nehemiah', 'Esth.' => 'Esther', 'Ps.' => 'Psalms', 'Prov.' => 'Proverbs', 'Eccl.' => 'Ecclesiastes', 'Song.' => 'Song of Solomon', 'Isa.' => 'Isaiah', 'Jer.' => 'Jeremiah', 'Lam.' => 'Lamentations', 'Ezek.' => 'Ezekiel', 'Dan.' => 'Daniel', 'Obad.' => 'Obadiah', 'Hab.' => 'Habakkuk', 'Zeph.' => 'Zephaniah', 'Hag.' => 'Haggai', 'Zech.' => 'Zechariah', 'Mal.' => 'Malachi', 'Matt.' => 'Matthew', 'Rom.' => 'Romans', '1 Cor.' => '1 Corinthians', '2 Cor.' => '2 Corinthians', 'Gal.' => 'Galatians', 'Eph.' => 'Ephesians', 'Philip.' => 'Philippians', 'Col.' => 'Colossians', '1 Thes.' => '1 Thessalonians', '2 Thes.' => '2 Thessalonians', '1 Tim.' => '1 Timothy', '2 Tim.' => '2 Timothy', 'Philem.' => 'Philemon', 'Heb.' => 'Hebrews', '1 Pet.' => '1 Peter', '2 Pet.' => '2 Peter', '1 Jn.' => '1 John', '2 Jn.' => '2 John', '3 Jn.' => '3 John', 'Rev.' => 'Revelation', '1 Ne.' => '1 Nephi', '2 Ne.' => '2 Nephi', 'W of M' => 'Words of Mormon', 'Hel.' => 'Helaman', '3 Ne.' => '3 Nephi', '4 Ne.' => '4 Nephi', 'Morm.' => 'Mormon', 'Moro.' => 'Moroni' } end
add_reference(verse)
click to toggle source
# File lib/standard_works/file_helper.rb, line 25 def self.add_reference(verse) @references[verse[:reference]] = verse[:text] end
all()
click to toggle source
# File lib/standard_works.rb, line 14 def self.all references end
books()
click to toggle source
# File lib/standard_works/file_helper.rb, line 39 def self.books [ 'book-of-mormon', 'doctrine-and-covenants', 'new-testament', 'old-testament', 'pearl-of-great-price' ] end
chapter_verses(power)
click to toggle source
# File lib/standard_works/file_helper.rb, line 29 def self.chapter_verses(power) # Get down to Verses power[:books].each do |sub_book| sub_book[:chapters].each do |chapter| chapter[:verses].each { |verse| add_reference(verse) } end end # And turn it into the main reference end
clear()
click to toggle source
# File lib/standard_works.rb, line 10 def self.clear @references = nil end
expand(term)
click to toggle source
# File lib/standard_works/abbreviations.rb, line 3 def self.expand(term) key = abrv.keys.find { |x| term.include? x } return term unless key term.gsub(key, abrv[key]) end
load_books()
click to toggle source
# File lib/standard_works/file_helper.rb, line 9 def self.load_books @references = {} books.each do |book| power = read book chapter_verses(power) if power.key? :books sections(power) if power.key? :sections end end
lookup(term)
click to toggle source
# File lib/standard_works.rb, line 22 def self.lookup(term) term = expand(term) verse = references.dig(term) verse = 'Unable to find Scripture' if verse.nil? { reference: term, verse: verse } end
read(file)
click to toggle source
# File lib/standard_works/file_helper.rb, line 49 def self.read(file) location = __dir__ Oj.load_file("#{location}/source/#{file}.json", OPTIONS) end
references()
click to toggle source
# File lib/standard_works.rb, line 29 def self.references load_books if @references.nil? @references end
sections(power)
click to toggle source
# File lib/standard_works/file_helper.rb, line 19 def self.sections(power) power[:sections].each do |section| section[:verses].each { |verse| add_reference(verse) } end end
verse(term)
click to toggle source
# File lib/standard_works.rb, line 18 def self.verse(term) lookup(term)[:verse] end