Class: IceAndFireApi::House
- Inherits:
-
Object
- Object
- IceAndFireApi::House
- Defined in:
- lib/ice_and_fire_api/house.rb
Instance Attribute Summary collapse
-
#ancestral_weapons ⇒ Object
readonly
Returns the value of attribute ancestral_weapons.
-
#cadet_branches ⇒ Object
readonly
Returns the value of attribute cadet_branches.
-
#coat_of_arms ⇒ Object
readonly
Returns the value of attribute coat_of_arms.
-
#current_lord ⇒ Object
readonly
Returns the value of attribute current_lord.
-
#died_out ⇒ Object
readonly
Returns the value of attribute died_out.
-
#founded ⇒ Object
readonly
Returns the value of attribute founded.
-
#founder ⇒ Object
readonly
Returns the value of attribute founder.
-
#heir ⇒ Object
readonly
Returns the value of attribute heir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#overlord ⇒ Object
readonly
Returns the value of attribute overlord.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#seats ⇒ Object
readonly
Returns the value of attribute seats.
-
#sworn_members ⇒ Object
readonly
Returns the value of attribute sworn_members.
-
#titles ⇒ Object
readonly
Returns the value of attribute titles.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#words ⇒ Object
readonly
Returns the value of attribute words.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ House
constructor
A new instance of House.
Constructor Details
#initialize(attributes) ⇒ House
Returns a new instance of House.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ice_and_fire_api/house.rb', line 9 def initialize(attributes) @url = attributes['url'] @name = attributes['name'] @region = attributes['region'] @coat_of_arms = attributes['coatOfArms'] @words = attributes['words'] @titles = attributes['titles'] @seats = attributes['seats'] @current_lord = attributes['currentLord'] @heir = attributes['heir'] @overlord = attributes['overlord'] @founded = attributes['founded'] @founder = attributes['founder'] @died_out = attributes['diedOut'] @ancestral_weapons = attributes['ancestralWeapons'] @cadet_branches = attributes['cadetBranches'] @sworn_members = attributes['swornMembers'] end |
Instance Attribute Details
#ancestral_weapons ⇒ Object (readonly)
Returns the value of attribute ancestral_weapons.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def ancestral_weapons @ancestral_weapons end |
#cadet_branches ⇒ Object (readonly)
Returns the value of attribute cadet_branches.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def cadet_branches @cadet_branches end |
#coat_of_arms ⇒ Object (readonly)
Returns the value of attribute coat_of_arms.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def coat_of_arms @coat_of_arms end |
#current_lord ⇒ Object (readonly)
Returns the value of attribute current_lord.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def current_lord @current_lord end |
#died_out ⇒ Object (readonly)
Returns the value of attribute died_out.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def died_out @died_out end |
#founded ⇒ Object (readonly)
Returns the value of attribute founded.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def founded @founded end |
#founder ⇒ Object (readonly)
Returns the value of attribute founder.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def founder @founder end |
#heir ⇒ Object (readonly)
Returns the value of attribute heir.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def heir @heir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def name @name end |
#overlord ⇒ Object (readonly)
Returns the value of attribute overlord.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def overlord @overlord end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def region @region end |
#seats ⇒ Object (readonly)
Returns the value of attribute seats.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def seats @seats end |
#sworn_members ⇒ Object (readonly)
Returns the value of attribute sworn_members.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def sworn_members @sworn_members end |
#titles ⇒ Object (readonly)
Returns the value of attribute titles.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def titles @titles end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def url @url end |
#words ⇒ Object (readonly)
Returns the value of attribute words.
3 4 5 |
# File 'lib/ice_and_fire_api/house.rb', line 3 def words @words end |
Class Method Details
.find(id) ⇒ Object
28 29 30 31 32 |
# File 'lib/ice_and_fire_api/house.rb', line 28 def self.find(id) response = Faraday.get("#{IceAndFireApi::API_URL}/houses/#{id}") attributes = JSON.parse(response.body) new(attributes) end |
.find_by_name(name) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ice_and_fire_api/house.rb', line 34 def self.find_by_name(name) name_query = URI.encode_www_form_component(name.to_s) response = Faraday.get("#{IceAndFireApi::API_URL}/houses?name=#{name_query}") attributes_response = JSON.parse(response.body) attributes_array = [] attributes_response.each do |attributes| attributes_array << new(attributes) end attributes_array end |