Class: GOTWrapper::House

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(house) ⇒ House

Returns a new instance of House.



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

def initialize(house)
  @name = house["name"]
  @region = house["region"]
  @words = house["words"]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/GOT_wrapper.rb', line 7

def name
  @name
end

#regionObject (readonly)

Returns the value of attribute region.



7
8
9
# File 'lib/GOT_wrapper.rb', line 7

def region
  @region
end

#wordsObject (readonly)

Returns the value of attribute words.



7
8
9
# File 'lib/GOT_wrapper.rb', line 7

def words
  @words
end

Class Method Details

.allObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/GOT_wrapper.rb', line 14

def self.all
    house_array = []
    i = 1
    while i < 41
      house_array << Unirest.get("http://www.anapioficeandfire.com/api/houses?page="+ i.to_s).body
      i += 1
    end
    houses = []
    house_array.each do |tenhouse|
      tenhouse.each do |house|
        houses << House.new(house)
      end
    end
    houses
end

.find_by(house_name) ⇒ Object



30
31
32
33
34
35
# File 'lib/GOT_wrapper.rb', line 30

def self.find_by(house_name)
    key = house_name.keys.first
    value = house_name.values.first
    house = Unirest.get("http://www.anapioficeandfire.com/api/houses?#{key}=#{value}").body
    House.new(house)
end