Class: ProverbsNiv

Inherits:
Object
  • Object
show all
Defined in:
lib/proverbs_niv.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chapter, verses, stop_worded_verses, rec_nsw) ⇒ ProverbsNiv

Returns a new instance of ProverbsNiv.



7
8
9
10
11
12
# File 'lib/proverbs_niv.rb', line 7

def initialize(chapter, verses, stop_worded_verses, rec_nsw)
  @chapter = chapter
  @verses = verses
  @stop_worded_verses = stop_worded_verses
  @rec_nsw = rec_nsw
end

Class Method Details

.getAllChapterNumbersObject



50
51
52
# File 'lib/proverbs_niv.rb', line 50

def self.getAllChapterNumbers
  return @outerHash.keys
end

.getChapterContent(chapNum) ⇒ Object



82
83
84
# File 'lib/proverbs_niv.rb', line 82

def self.getChapterContent(chapNum)
  return @outerHash[chapNum.to_s]
end

.getChapterVerses(chapNum) ⇒ Object



86
87
88
# File 'lib/proverbs_niv.rb', line 86

def self.getChapterVerses(chapNum)
  return @outerHash[chapNum.to_s]["verses"]
end

.getContentOfAllChaptersObject



54
55
56
# File 'lib/proverbs_niv.rb', line 54

def self.getContentOfAllChapters
  return @outerHash
end

.getRecurCountNoSw(chapNum) ⇒ Object



90
91
92
# File 'lib/proverbs_niv.rb', line 90

def self.getRecurCountNoSw(chapNum)
  return @outerHash[chapNum.to_s]["rec_nsw"]
end

.getRecurCountNoSwAllChaptersObject



66
67
68
69
70
71
72
# File 'lib/proverbs_niv.rb', line 66

def self.getRecurCountNoSwAllChapters
  @verses = Hash.new
  @outerHash.each do |chap_num, chap_value|
    @verses[chap_num] = chap_value["rec_nsw"]
  end  
  return @verses
end

.getRecurCountSw(chapNum) ⇒ Object



94
95
96
# File 'lib/proverbs_niv.rb', line 94

def self.getRecurCountSw(chapNum)
  return @outerHash[chapNum.to_s]["sw_rec_count"]
end

.getRecurCountSwAllChaptersObject



74
75
76
77
78
79
80
# File 'lib/proverbs_niv.rb', line 74

def self.getRecurCountSwAllChapters
  @verses = Hash.new
  @outerHash.each do |chap_num, chap_value|
    @verses[chap_num] = chap_value["sw_rec_count"]
  end  
  return @verses
end

.getVersesOfAllChaptersObject



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

def self.getVersesOfAllChapters
  @verses = Hash.new
  @outerHash.each do |chap_num, chap_value|
    @verses[chap_num] = chap_value["verses"]
  end  
  return @verses
end

.initObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/proverbs_niv.rb', line 30

def self.init
  uri = URI("http://bookofproverbs.herokuapp.com/api/v1/niv_bible")

  http = Net::HTTP.new(uri.host, uri.port)
  req = Net::HTTP::Get.new(uri.path)
  resp = http.request(req)

  data = JSON.parse(resp.body)
  data.each do |key, value|
    @localHash = Hash.new
    @proverb = ProverbsNiv.new(key, value["verses"], value["stop_worded_verses"], value["rec_nsw"])
    @localHash["chapter"] = @proverb.get_chapter
    @localHash["verses"] = @proverb.get_verses
    @localHash["rec_nsw"] = @proverb.get_rec_nsw
    @localHash["sw_rec_count"] = @proverb.get_sw_count
    @outerHash[@proverb.get_chapter] = @localHash
  end
  return "init complete"
end

Instance Method Details

#get_chapterObject



14
15
16
# File 'lib/proverbs_niv.rb', line 14

def get_chapter
  return @chapter
end

#get_rec_nswObject



26
27
28
# File 'lib/proverbs_niv.rb', line 26

def get_rec_nsw
  return @rec_nsw
end

#get_sw_countObject



22
23
24
# File 'lib/proverbs_niv.rb', line 22

def get_sw_count
  return @stop_worded_verses
end

#get_versesObject



18
19
20
# File 'lib/proverbs_niv.rb', line 18

def get_verses
  return @verses
end