Class: Votd::BibleGateway

Inherits:
Base
  • Object
show all
Defined in:
lib/votd/bible_gateway.rb

Overview

Retrieves a Verse of the Day from biblegateway.com using a variety of translations.

Default translation is NIV (New International Version).

Examples:

Fetch the default (NIV) verse of the day

votd = Votd::BibleGateway.new
votd.text       # => "For God so loved the world..."
votd.reference  # => "John 3:16"

Fetch the KJV verse of the day

votd = Votd::BibleGateway.new(:kjv)

See Also:

Constant Summary collapse

BIBLE_VERSIONS =

These are the English translations that are copyright-approved for Bible Gateway VotD as of November 2019.

{
  amp: {name: "Amplified Bible", id: 45},
  asv: {name: "American Standard Version", id: 8},
  ceb: {name: "Common English Bible", id: 105},
  darby: {name: "Darby Translation", id: 16},
  esv: {name: "English Standard Version", id: 47},
  esvu: {name: "English Standard Version Anglicised", id: 166},
  gw: {name: "God's Word Translation", id: 158},
  hcsb: {name: "Holman Christian Standard Bible", id: 77},
  kjv: {name: "King James Version", id: 9},
  leb: {name: "Lexham English Bible", id: 165},
  nasb: {name: "New American Standard Bible", id: 49},
  nirv: {name: "New International Reader's Version", id: 76},
  niv: {name: "New International Version", id: 31},
  nivuk: {name: "New International Version - UK", id: 64},
  nlt: {name: "New Living Translation", id: 51},
  nlv: {name: "New Life Version", id: 74},
  phillips: {name: "J.B. Phillips New Testament", id: 164},
  we: {name: "Worldwide English (New Testament)", id: 73},
  wyc: {name: "Wycliffe Bible", id: 53},
  ylt: {name: "Young's Literal Translation", id: 15}
}
ENDPOINT_URL =

The URL of the API gateway

"https://www.biblegateway.com/usage/votd/rss/votd.rdf?"
/(Brought to you by BibleGateway.*$)/

Instance Method Summary collapse

Constructor Details

#initialize(version = :niv) ⇒ BibleGateway

Initializes the BibleGateway class and fetches the verse of the day.

Parameters:

  • version (Symbol) (defaults to: :niv)

    the Bible translation key (e.g. :niv, :kjv, :esv). Must be a key in BIBLE_VERSIONS.

Raises:



58
59
60
61
62
63
64
65
# File 'lib/votd/bible_gateway.rb', line 58

def initialize(version = :niv)
  raise InvalidBibleVersion unless BIBLE_VERSIONS.key?(version)

  @version = version.to_s.upcase
  @version_number = BIBLE_VERSIONS[version][:id]
  @version_name = BIBLE_VERSIONS[version][:name]
  super()
end