Class: Kiva::Location
- Inherits:
-
Object
- Object
- Kiva::Location
- Includes:
- DynamicInitializer
- Defined in:
- lib/ruby-kiva/location.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#geo ⇒ Object
Returns the value of attribute geo.
-
#level ⇒ Object
Returns the value of attribute level.
-
#town ⇒ Object
Returns the value of attribute town.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#box? ⇒ Boolean
true if type ‘box’.
-
#country? ⇒ Boolean
true if level is ‘country’.
-
#exact? ⇒ Boolean
true if level ‘exact’.
-
#lat ⇒ Object
if this is a point?, then returns lat else nil.
-
#line? ⇒ Boolean
true if type ‘line’.
-
#lng ⇒ Object
if this is a point?, then returns lat else nil.
- #pairs ⇒ Object
- #pairs=(value) ⇒ Object
-
#point? ⇒ Boolean
true if type ‘point’.
-
#polygon? ⇒ Boolean
true if type ‘polygon’.
- #to_s ⇒ Object
-
#town? ⇒ Boolean
true if level is ‘town’.
Methods included from DynamicInitializer
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
4 5 6 |
# File 'lib/ruby-kiva/location.rb', line 4 def country @country end |
#country_code ⇒ Object
Returns the value of attribute country_code.
5 6 7 |
# File 'lib/ruby-kiva/location.rb', line 5 def country_code @country_code end |
#geo ⇒ Object
Returns the value of attribute geo.
4 5 6 |
# File 'lib/ruby-kiva/location.rb', line 4 def geo @geo end |
#level ⇒ Object
Returns the value of attribute level.
4 5 6 |
# File 'lib/ruby-kiva/location.rb', line 4 def level @level end |
#town ⇒ Object
Returns the value of attribute town.
4 5 6 |
# File 'lib/ruby-kiva/location.rb', line 4 def town @town end |
#type ⇒ Object
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’
54 55 56 |
# File 'lib/ruby-kiva/location.rb', line 54 def box? 'box' == self.type end |
#country? ⇒ Boolean
true if level is ‘country’
37 38 39 |
# File 'lib/ruby-kiva/location.rb', line 37 def country? 'country' == self.level end |
#exact? ⇒ Boolean
true if level ‘exact’
41 42 43 |
# File 'lib/ruby-kiva/location.rb', line 41 def exact? 'exact' == self.level end |
#lat ⇒ Object
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’
50 51 52 |
# File 'lib/ruby-kiva/location.rb', line 50 def line? 'line' == self.type end |
#lng ⇒ Object
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 |
#pairs ⇒ Object
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’
46 47 48 |
# File 'lib/ruby-kiva/location.rb', line 46 def point? 'point' == self.type end |
#polygon? ⇒ Boolean
true if type ‘polygon’
58 59 60 |
# File 'lib/ruby-kiva/location.rb', line 58 def polygon? 'polygon' == self.type end |
#to_s ⇒ Object
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’
33 34 35 |
# File 'lib/ruby-kiva/location.rb', line 33 def town? 'town' == self.level end |