Class: Kiva::Location

Inherits:
Object
  • Object
show all
Includes:
DynamicInitializer
Defined in:
lib/ruby-kiva/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DynamicInitializer

included

Instance Attribute Details

#countryObject

Returns the value of attribute country.



4
5
6
# File 'lib/ruby-kiva/location.rb', line 4

def country
  @country
end

#country_codeObject

Returns the value of attribute country_code.



5
6
7
# File 'lib/ruby-kiva/location.rb', line 5

def country_code
  @country_code
end

#geoObject

Returns the value of attribute geo.



4
5
6
# File 'lib/ruby-kiva/location.rb', line 4

def geo
  @geo
end

#levelObject

Returns the value of attribute level.



4
5
6
# File 'lib/ruby-kiva/location.rb', line 4

def level
  @level
end

#townObject

Returns the value of attribute town.



4
5
6
# File 'lib/ruby-kiva/location.rb', line 4

def town
  @town
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/ruby-kiva/location.rb', line 4

def type
  @type
end

Instance Method Details

#box?Boolean

true if type ‘box’

Returns:

  • (Boolean)


54
55
56
# File 'lib/ruby-kiva/location.rb', line 54

def box?
  'box' == self.type
end

#country?Boolean

true if level is ‘country’

Returns:

  • (Boolean)


37
38
39
# File 'lib/ruby-kiva/location.rb', line 37

def country?
  'country' == self.level
end

#exact?Boolean

true if level ‘exact’

Returns:

  • (Boolean)


41
42
43
# File 'lib/ruby-kiva/location.rb', line 41

def exact?
  'exact' == self.level
end

#latObject

if this is a point?, then returns lat else nil



23
24
25
# File 'lib/ruby-kiva/location.rb', line 23

def lat
  @pairs[0] if self.point?
end

#line?Boolean

true if type ‘line’

Returns:

  • (Boolean)


50
51
52
# File 'lib/ruby-kiva/location.rb', line 50

def line?
  'line' == self.type
end

#lngObject

if this is a point?, then returns lat else nil



28
29
30
# File 'lib/ruby-kiva/location.rb', line 28

def lng
  @pairs[1] if self.point?
end

#pairsObject



17
18
19
# File 'lib/ruby-kiva/location.rb', line 17

def pairs
  @pairs.join(' ')
end

#pairs=(value) ⇒ Object



13
14
15
# File 'lib/ruby-kiva/location.rb', line 13

def pairs=(value)
  @pairs = value.split(' ').map() {|item| item.to_f}
end

#point?Boolean

true if type ‘point’

Returns:

  • (Boolean)


46
47
48
# File 'lib/ruby-kiva/location.rb', line 46

def point?
  'point' == self.type
end

#polygon?Boolean

true if type ‘polygon’

Returns:

  • (Boolean)


58
59
60
# File 'lib/ruby-kiva/location.rb', line 58

def polygon?
  'polygon' == self.type
end

#to_sObject



62
63
64
# File 'lib/ruby-kiva/location.rb', line 62

def to_s
  "<Location '%s' '%s' %f/%f>" % [self.country, self.town, self.lat || 0, self.lng || 0]
end

#town?Boolean

true if level is ‘town’

Returns:

  • (Boolean)


33
34
35
# File 'lib/ruby-kiva/location.rb', line 33

def town?
  'town' == self.level
end