Class: TextMe::BibleExtractor
- Inherits:
-
Object
- Object
- TextMe::BibleExtractor
- Defined in:
- lib/textme-jtj.rb
Overview
Helper Class to generate the url from a verse name
Instance Method Summary collapse
-
#book_name_formatter(book_name) ⇒ Object
Helper Method What: It is a very long switch statement (order maintained) that transform the bible book name Input: Name of the specific book of the bible - eg.
-
#verse_meta_extractor(verse_name) ⇒ Object
Helper Method What: Take in the verse name and return the metadata as a Hash.
-
#verse_url_generator(verse_name) ⇒ Object
What: Is called from the Core class.
Instance Method Details
#book_name_formatter(book_name) ⇒ Object
Helper Method What: It is a very long switch statement (order maintained) that transform the bible book name Input: Name of the specific book of the bible - eg. ‘Psalms’ Output: The You Version url specific book name
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/textme-jtj.rb', line 141 def book_name_formatter(book_name) transformed_name = nil case book_name when"Genesis" transformed_name = "gen" when"Exodus" transformed_name = "exo" when"Leviticus" transformed_name = "lev" when"Numbers" transformed_name = "num" when"Deuteronomy" transformed_name = "deu" when"Joshua" transformed_name = "jos" when"Judges" transformed_name = "jdg" when"Ruth" transformed_name = "rut" when"1 Samuel" transformed_name = "1sa" when"2 Samuel" transformed_name = "2sa" when"1 Kings" transformed_name = "1ki" when"2 Kings" transformed_name = "2ki" when"1 Chronicles" transformed_name = "1ch" when"2 Chronicles" transformed_name = "2ch" when"Ezra" transformed_name = "ezr" when"Nehemiah" transformed_name = "neh" when"Esther" transformed_name = "est" when "Job" transformed_name = "job" when "Psalms" transformed_name = "psa" when "Proverbs" transformed_name = "pro" when "Ecclesiastes" transformed_name = "ecc" when "Song of Songs" transformed_name = "sng" when "Isaiah" transformed_name = "isa" when "Jeremiah" transformed_name = "jer" when "Lamentations" transformed_name = "lam" when "Ezekiel" transformed_name = "ezk" when "Daniel" transformed_name = "dan" when "Hosea" transformed_name = "hos" when "Joel" transformed_name = "jol" when "Amos" transformed_name = "amo" when "Obadiah" transformed_name = "oba" when "Jonah" transformed_name = "jon" when "Micah" transformed_name = "mic" when "Nahum" transformed_name = "nam" when "Habakkuk" transformed_name = "hab" when "Zephaniah" transformed_name = "zep" when "Haggai" transformed_name = "hag" when "Zechariah" transformed_name = "zec" when "Malachi" transformed_name = "mal" when "Matthew" transformed_name = "mat" when "Mark" transformed_name = "mek" when "Luke" transformed_name = "luk" when "John" transformed_name = "jhn" when "Acts" transformed_name = "act" when "Romans" transformed_name = "rom" when "1 Corinthians" transformed_name = "1co" when "2 Corinthians" transformed_name = "2co" when "Galatians" transformed_name = "gal" when "Ephesians" transformed_name = "eph" when "Philippians" transformed_name = "php" when "Colossians" transformed_name = "col" when "1 Thessalonians" transformed_name = "1th" when "2 Thessalonians" transformed_name = "2th" when "1 Timothy" transformed_name = "1ti" when "2 Timothy" transformed_name = "2ti" when "Titus" transformed_name = "tit" when "Philemon" transformed_name = "phm" when "Hebrews" transformed_name = "heb" when "James" transformed_name = "jas" when "1 Peter" transformed_name = "1pe" when "2 Peter" transformed_name = "2pe" when "1 John" transformed_name = "1jn" when "2 John" transformed_name = "2jn" when "3 John" transformed_name = "3jn" when "Jude" transformed_name = "jud" when "Revelation" transformed_name = "rev" end end |
#verse_meta_extractor(verse_name) ⇒ Object
Helper Method What: Take in the verse name and return the metadata as a Hash. Input: Verse name, for example ‘Proverbs 3:5-6’. Can also accept chapter names eg. ‘Romans 3’ (not recommended due to the length of the chapters) Output: Returns the book, chapter number and the specfic verse (optional) rfom the verse name
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/textme-jtj.rb', line 96 def (verse_name) book_list =["Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy", "Joshua", "Judges", "Ruth", "1 Samuel", "2 Samuel", "1 Kings", "2 Kings", "1 Chronicles", "2 Chronicles", "Ezra", "Nehemiah", "Esther", "Job", "Psalms", "Proverbs", "Ecclesiastes", "Song of Songs", "Isaiah", "Jeremiah", "Lamentations", "Ezekiel", "Daniel", "Hosea", "Joel", "Amos", "Obadiah", "Jonah", "Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai", "Zechariah", "Malachi", "Matthew", "Mark", "Luke", "John", "Acts", "Romans", "1 Corinthians", "2 Corinthians", "Galatians", "Ephesians", "Philippians", "Colossians", "1 Thessalonians", "2 Thessalonians", "1 Timothy", "2 Timothy", "Titus", "Philemon", "Hebrews", "James", "1 Peter", "2 Peter", "1 John", "2 John", "3 John", "Jude", "Revelation"] = {} #Loop through the book_list to see which book verse name contains for book in book_list if verse_name.downcase.include? book.downcase ["book"] = book #Split the rest of the verse name into list (chapter number + verse number) verse_number = verse_name.split(book)[1].strip #To check if the whole chapter is requested or specific verses if verse_number.include? ':' ['chapter_number'] = verse_number.split(':')[0].strip ['specific_verse'] = verse_number.split(':')[1].strip else ['chapter_number'] = verse_number end end end return end |
#verse_url_generator(verse_name) ⇒ Object
What: Is called from the Core class. Gets the verse name and calls verse_meta_extractor. Uses the meta data and book_name_formatter to generate th You Version url Input: Verse name, for example ‘Proverbs 3:5-6’. Can also accept chapter names eg. ‘Romans 3’ (not recommended due to the length of the chapters) Output: You version url of the verse
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/textme-jtj.rb', line 125 def verse_url_generator(verse_name) = (verse_name) url = 'https://bible.com/bible/59/' #base url url = url + book_name_formatter(['book']) + '/' #book name url = url + ["chapter_number"] + '/' #chapter number #add verse number only if not just book name if ['specific_verse'] url = url + ['specific_verse'] end return url end |