Class: IceAndFireApi::Root
- Inherits:
-
Object
- Object
- IceAndFireApi::Root
- Defined in:
- lib/ice_and_fire_api/root.rb
Instance Attribute Summary collapse
-
#books ⇒ Object
readonly
Returns the value of attribute books.
-
#characters ⇒ Object
readonly
Returns the value of attribute characters.
-
#houses ⇒ Object
readonly
Returns the value of attribute houses.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Root
constructor
A new instance of Root.
Constructor Details
#initialize(attributes) ⇒ Root
Returns a new instance of Root.
5 6 7 8 9 |
# File 'lib/ice_and_fire_api/root.rb', line 5 def initialize(attributes) @books = attributes['books'] @characters = attributes['characters'] @houses = attributes['houses'] end |
Instance Attribute Details
#books ⇒ Object (readonly)
Returns the value of attribute books.
3 4 5 |
# File 'lib/ice_and_fire_api/root.rb', line 3 def books @books end |
#characters ⇒ Object (readonly)
Returns the value of attribute characters.
3 4 5 |
# File 'lib/ice_and_fire_api/root.rb', line 3 def characters @characters end |
#houses ⇒ Object (readonly)
Returns the value of attribute houses.
3 4 5 |
# File 'lib/ice_and_fire_api/root.rb', line 3 def houses @houses end |
Class Method Details
.fetch ⇒ Object
11 12 13 14 15 |
# File 'lib/ice_and_fire_api/root.rb', line 11 def self.fetch response = Faraday.get(IceAndFireApi::API_URL.to_s) attributes = JSON.parse(response.body) new(attributes) end |