Class: ESV::Bible

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/esv/bible.rb

Instance Method Summary collapse

Constructor Details

#initialize(default_options = {}) ⇒ Bible

The ESV API requires a key that can be passed in as one of the options, :key => ‘value’. By default, it is ‘IP’



10
11
12
13
# File 'lib/esv/bible.rb', line 10

def initialize(default_options={})
  @default_options = default_options
  @default_options[:key] ||= 'IP'
end

Instance Method Details

#daily_verse(options = {}) ⇒ Object

Display a verse that changes every day

See www.esvapi.org/api for more information and options



51
52
53
# File 'lib/esv/bible.rb', line 51

def daily_verse(options={})
  self.class.get '/dailyVerse', :query => @default_options.merge(options)
end

#passage_query(passage, options = {}) ⇒ Object

Lookup a passage

See www.esvapi.org/api for more information and options



18
19
20
21
# File 'lib/esv/bible.rb', line 18

def passage_query(passage, options={})
  options[:passage] = passage
  self.class.get '/passageQuery', :query => @default_options.merge(options)
end

#query(q, options = {}) ⇒ Object

Look up a passage or show word-search results, depending on the query

The output format is always HTML.

See www.esvapi.org/api for more information and options



28
29
30
31
# File 'lib/esv/bible.rb', line 28

def query(q, options={})
  options[:q] = q
  self.class.get '/query', :query => @default_options.merge(options)
end

#query_info(q) ⇒ Object

Parse and display information about your query, including identify whether it is a passage reference or a word search

See www.esvapi.org/api for more information and options



36
37
38
39
# File 'lib/esv/bible.rb', line 36

def query_info(q)
  options = {:q => q}
  self.class.get '/queryInfo', :query =>  @default_options.merge(options)
end

#verse(options = {}) ⇒ Object

Display a random verse from a preselected list, or specify verse(s)

See www.esvapi.org/api for more information and options



44
45
46
# File 'lib/esv/bible.rb', line 44

def verse(options={})
  self.class.get '/verse', :query => @default_options.merge(options)
end