Class: GolfSwitch::AreaResponse
- Inherits:
-
Object
- Object
- GolfSwitch::AreaResponse
- Defined in:
- lib/golf_switch/area_response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#area_id ⇒ Object
Returns the value of attribute area_id.
-
#countries ⇒ Object
Returns the value of attribute countries.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(area_id = nil, name = nil) ⇒ AreaResponse
constructor
A new instance of AreaResponse.
Constructor Details
#initialize(area_id = nil, name = nil) ⇒ AreaResponse
Returns a new instance of AreaResponse.
4 5 6 7 8 |
# File 'lib/golf_switch/area_response.rb', line 4 def initialize(area_id=nil,name=nil) @area_id = area_id @name = name @countries= [] end |
Instance Attribute Details
#area_id ⇒ Object
Returns the value of attribute area_id.
3 4 5 |
# File 'lib/golf_switch/area_response.rb', line 3 def area_id @area_id end |
#countries ⇒ Object
Returns the value of attribute countries.
3 4 5 |
# File 'lib/golf_switch/area_response.rb', line 3 def countries @countries end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/golf_switch/area_response.rb', line 3 def name @name end |
Class Method Details
.parse_areas(response_hash) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/golf_switch/area_response.rb', line 10 def self.parse_areas(response_hash) areas = AreaResponse.new unless response_hash[:countries] && response_hash[:countries].blank? # Searching for single country if response_hash[:countries][:country] && response_hash[:countries][:country].is_a?(Hash) areas.countries << Country.parse_country(response_hash[:countries][:country]) elsif response_hash[:countries][:country] && response_hash[:countries][:country].is_a?(Array) response_hash[:countries][:country].each do |country| areas.countries << Country.parse_country(country) end end end areas end |