Class: Yahoo::Placemaker::LocalScope

Inherits:
Scope
  • Object
show all
Defined in:
lib/yahoo/placemaker/local_scope.rb

Instance Attribute Summary (collapse)

Attributes inherited from Scope

#name, #type, #woe_id

Instance Method Summary (collapse)

Constructor Details

- (LocalScope) initialize(json)

A new instance of LocalScope



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/yahoo/placemaker/local_scope.rb', line 10

def initialize (json)
  super(json)
  @centroid = Yahoo::Placemaker::LatLng.new json['centroid']
  @south_west = Yahoo::Placemaker::LatLng.new json['southWest']
  @north_east = Yahoo::Placemaker::LatLng.new json['northEast']

  # Yahoo doesn't always return an array of ancestors; ancestors can
  # be an array, a hash, or a string containing "\n"?! We need to
  # account for this and stuff everything into @ancestors...

  @ancestors = Array.new
  if json['ancestors'].class == Array
    json['ancestors'].each do |ancestor|
      @ancestors << Yahoo::Placemaker::Ancestor.new(ancestor['ancestor'])
    end
  elsif json['ancestors'].class == Hash
      @ancestors << Yahoo::Placemaker::Ancestor.new(json['ancestors']['ancestor'])
  else
    # no ancestors...country?
  end
end

Instance Attribute Details

- (Object) ancestors

Returns the value of attribute ancestors



8
9
10
# File 'lib/yahoo/placemaker/local_scope.rb', line 8

def ancestors
  @ancestors
end

- (Object) centroid

Returns the value of attribute centroid



8
9
10
# File 'lib/yahoo/placemaker/local_scope.rb', line 8

def centroid
  @centroid
end

- (Object) north_east

Returns the value of attribute north_east



8
9
10
# File 'lib/yahoo/placemaker/local_scope.rb', line 8

def north_east
  @north_east
end

- (Object) south_west

Returns the value of attribute south_west



8
9
10
# File 'lib/yahoo/placemaker/local_scope.rb', line 8

def south_west
  @south_west
end