Class: Oceanarium::Region
- Inherits:
-
Object
- Object
- Oceanarium::Region
- Defined in:
- lib/oceanarium/resources/region.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#slug ⇒ Object
Returns the value of attribute slug.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(option, api_key, client_id) ⇒ Region
constructor
A new instance of Region.
Constructor Details
#initialize(option, api_key, client_id) ⇒ Region
Returns a new instance of Region.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/oceanarium/resources/region.rb', line 5 def initialize(option, api_key, client_id) if api_key.nil? || client_id.nil? raise 'No API key/client ID!' else if option.is_a?(Hash) @object = option end if @object.nil? self.id = nil else self.id = @object['id'] self.name = @object['name'] self.slug = @object['slug'] end end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/oceanarium/resources/region.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/oceanarium/resources/region.rb', line 3 def name @name end |
#slug ⇒ Object
Returns the value of attribute slug.
3 4 5 |
# File 'lib/oceanarium/resources/region.rb', line 3 def slug @slug end |
Class Method Details
.all ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/oceanarium/resources/region.rb', line 22 def self.all # Returns all avaliable regions in Array @request = Oceanarium::Request.new @get = @request.get('/regions/') if @get.parsed_response['status'] == 'OK' @get.parsed_response['regions'] end end |