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.
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/GOT_wrapper.rb', line 6 def name @name end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
6 7 8 |
# File 'lib/GOT_wrapper.rb', line 6 def region @region end |
#words ⇒ Object (readonly)
Returns the value of attribute words.
6 7 8 |
# File 'lib/GOT_wrapper.rb', line 6 def words @words end |
Class Method Details
.all ⇒ Object
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 |