Class: Bible::RSVLookup
- Inherits:
-
Object
- Object
- Bible::RSVLookup
- Defined in:
- lib/bible/lookup/rsv.rb
Constant Summary collapse
- @@books =
{}
Class Method Summary collapse
Class Method Details
.get_ref(book, chapter, verse) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bible/lookup/rsv.rb', line 27 def self.get_ref(book, chapter , verse ) raise "Verse cannot be nil for RSV lookup." if verse.nil? raise "Chapter cannot be nil for RSV lookup." if chapter.nil? text = ((@@books[book] ||= {})[chapter] ||= open(getURL(book, chapter)).gets(nil)) scanner = StringScanner.new(text) if ! verse.nil? if ! scanner.skip_until(/<i>#{verse}:<\/i>/) scanner = StringScanner.new("") else scanner = StringScanner.new(scanner.scan_until(/(<br>|<\/p>)/)[0 ... scanner[1].length * -1]) end end if scanner.empty? "" else scanner.rest end end |
.getURL(book, chapter) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bible/lookup/rsv.rb', line 7 def self.getURL(book, chapter) raise "chapter cannot be nil" if chapter.nil? case book when %s(1 Kings) b = "1Kgs" when %s(2 Kings) b = "2Kgs" when :Job b = "BJob" when %s(Song of Solomon) b = "Cant" when :Philemon b = "Phlm" else b = book.to_s.split(" ").join("")[0 ... 4] end "http://etext.lib.virginia.edu/etcbin/toccer-new2?id=Rsv#{b}.sgm&images=images/modeng&data=/texts/english/modeng/parsed&tag=public&part=#{chapter}&division=div1" end |