Class: GolfSwitch::Country

Inherits:
AreaResponse show all
Defined in:
lib/golf_switch/country.rb

Instance Attribute Summary collapse

Attributes inherited from AreaResponse

#area_id, #countries, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AreaResponse

parse_areas

Constructor Details

#initialize(area_id = nil, name = nil) ⇒ Country

Returns a new instance of Country.



4
5
6
7
# File 'lib/golf_switch/country.rb', line 4

def initialize(area_id=nil,name=nil)
  super(area_id,name)
  @country_regions = []
end

Instance Attribute Details

#country_regionsObject

Returns the value of attribute country_regions.



3
4
5
# File 'lib/golf_switch/country.rb', line 3

def country_regions
  @country_regions
end

Class Method Details

.parse_country(country) ⇒ Object



9
10
11
12
13
# File 'lib/golf_switch/country.rb', line 9

def self.parse_country(country)
  golfswitch_country = Country.new(country[:id],country[:nm])
  golfswitch_country.parse_regions(country[:regions])
  golfswitch_country
end

Instance Method Details

#parse_regions(regions) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/golf_switch/country.rb', line 19

def parse_regions(regions)

  if regions[:region] && regions[:region].is_a?(Array)
    regions[:region].each do |region|
      @country_regions << CountryRegion.parse_region(region)
    end
  elsif  regions[:region] && regions.is_a?(Hash)
    @country_regions << CountryRegion.parse_region(regions[:region])
  end
end

#regionsObject



15
16
17
# File 'lib/golf_switch/country.rb', line 15

def regions
  @country_regions
end