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.



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

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#regionObject (readonly)

Returns the value of attribute region.



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

def region
  @region
end

#wordsObject (readonly)

Returns the value of attribute words.



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

def words
  @words
end

Class Method Details

.allObject



13
14
15
16
17
18
19
20
# File 'lib/GOT_wrapper.rb', line 13

def self.all
    houses_array = Unirest.get("http://www.anapioficeandfire.com/api/houses?").body
    houses = []
    houses_array.each do |house|
      houses << House.new(house)
    end
    houses
end

.find_by(house_name) ⇒ Object



22
23
24
25
26
27
# File 'lib/GOT_wrapper.rb', line 22

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