Class: Geogov::FuzzyPoint
- Inherits:
-
Object
- Object
- Geogov::FuzzyPoint
- Defined in:
- lib/geogov/fuzzy_point.rb
Constant Summary collapse
- ACCURACIES =
[:point,:postcode,:postcode_district,:ward,:council,:nation,:country,:planet]
Instance Attribute Summary collapse
-
#accuracy ⇒ Object
readonly
Returns the value of attribute accuracy.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#lon ⇒ Object
readonly
Returns the value of attribute lon.
Instance Method Summary collapse
-
#initialize(lat, lon, accuracy) ⇒ FuzzyPoint
constructor
A new instance of FuzzyPoint.
- #to_hash ⇒ Object
Constructor Details
#initialize(lat, lon, accuracy) ⇒ FuzzyPoint
Returns a new instance of FuzzyPoint.
8 9 10 11 12 13 14 15 16 |
# File 'lib/geogov/fuzzy_point.rb', line 8 def initialize(lat,lon,accuracy) accuracy = accuracy.to_sym raise ValueError unless ACCURACIES.include?(accuracy) @lon,@lat,@accuracy = lon.to_f, lat.to_f, accuracy if @accuracy == :point @lon = @lon.round(2) @lat = @lat.round(2) end end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
Returns the value of attribute accuracy.
5 6 7 |
# File 'lib/geogov/fuzzy_point.rb', line 5 def accuracy @accuracy end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
5 6 7 |
# File 'lib/geogov/fuzzy_point.rb', line 5 def lat @lat end |
#lon ⇒ Object (readonly)
Returns the value of attribute lon.
5 6 7 |
# File 'lib/geogov/fuzzy_point.rb', line 5 def lon @lon end |
Instance Method Details
#to_hash ⇒ Object
18 19 20 |
# File 'lib/geogov/fuzzy_point.rb', line 18 def to_hash {"lon"=> self.lon.to_s,"lat"=>self.lat.to_s,"accuracy"=>accuracy.to_s} end |