Class: GolfSwitch::CountryRegion

Inherits:
AreaResponse show all
Defined in:
lib/golf_switch/country_region.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) ⇒ CountryRegion

Returns a new instance of CountryRegion.



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

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

Instance Attribute Details

#region_areasObject

Returns the value of attribute region_areas.



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

def region_areas
  @region_areas
end

Class Method Details

.parse_region(region) ⇒ Object



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

def self.parse_region(region)
  golfswitch_region = CountryRegion.new(region[:id],region[:nm])
  golfswitch_region.parse_region_areas(region[:areas])
  golfswitch_region
end

Instance Method Details

#areasObject



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

def areas
  @region_areas
end

#parse_region_areas(areas) ⇒ Object



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

def parse_region_areas(areas)
   if areas[:area] && areas[:area].is_a?(Array)
    areas[:area].each do |area|
      @region_areas << RegionArea.parse_region_area(area)
    end
  elsif  areas[:area] && areas[:area].is_a?(Hash)
    @region_areas << RegionArea.parse_region_area(areas[:area])
  end
end