class Votd::ESVBible
Retrieves a Verse of the Day from www.gnpcb.org, Good News Publishers, Crossway Bibles, using the English Standard Version translation (ESV).
Constants
- BIBLE_VERSION
The name of the Bible Translation that this module generates
- BIBLE_VERSION_NAME
- URI
The
URI
of the API gateway
Public Class Methods
new()
click to toggle source
Initializes the ESVBible
class @return [Votd::ESVBible]
Calls superclass method
Votd::Base::new
# File lib/votd/esvbible.rb, line 17 def initialize super() end
Private Instance Methods
clean_copyright(text)
click to toggle source
Cleans up the copyright. Removes:
- Tabs, line breaks
Inserts:
- Missing space after commas
@return [String]
# File lib/votd/esvbible.rb, line 50 def clean_copyright(text) text = text.gsub(/[\t\n]/, '') text = text.gsub(/,(?!\s)/, ', ') end
get_votd()
click to toggle source
Gets the votd from the Good News Publishers, Crossway Bibles, RSS feed @return [String]
# File lib/votd/esvbible.rb, line 26 def get_votd parsed_feed = Nokogiri::XML(HTTParty.get(URI).body) cleaned_copyright = clean_copyright(parsed_feed.xpath("//copyright").text) @reference = parsed_feed.xpath("//title")[1].text @text = parsed_feed.xpath("//description")[1].text @copyright = cleaned_copyright @link = parsed_feed.xpath("//guid").text @version = BIBLE_VERSION @version_name = BIBLE_VERSION_NAME @text = Helper::Text.clean_verse_start(@text) @text = Helper::Text.clean_verse_end(@text) rescue => e # use default info for VotD set_defaults end