Class: GOTWrapper::House
- Inherits:
-
Object
- Object
- GOTWrapper::House
- Defined in:
- lib/GOT_wrapper.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#words ⇒ Object
readonly
Returns the value of attribute words.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(house) ⇒ House
constructor
A new instance of House.
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/GOT_wrapper.rb', line 7 def name @name end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
7 8 9 |
# File 'lib/GOT_wrapper.rb', line 7 def region @region end |
#words ⇒ Object (readonly)
Returns the value of attribute words.
7 8 9 |
# File 'lib/GOT_wrapper.rb', line 7 def words @words end |
Class Method Details
.all ⇒ Object
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 |