class Geospatial::Distance
This location is specifically relating to a WGS84 coordinate on Earth.
Constants
- UNITS
Public Class Methods
new(value)
click to toggle source
Distance
in meters:
# File lib/geospatial/distance.rb, line 27 def initialize(value) @value = value @formatted_value = nil end
Public Instance Methods
*(other)
click to toggle source
# File lib/geospatial/distance.rb, line 70 def * other Distance.new(@value * other.to_f) end
+(other)
click to toggle source
# File lib/geospatial/distance.rb, line 62 def + other Distance.new(@value + other.to_f) end
-(other)
click to toggle source
# File lib/geospatial/distance.rb, line 66 def - other Distance.new(@value - other.to_f) end
/(other)
click to toggle source
# File lib/geospatial/distance.rb, line 74 def / other Distance.new(@value / other.to_f) end
<=>(other)
click to toggle source
# File lib/geospatial/distance.rb, line 82 def <=> other @value <=> other.to_f end
==(other)
click to toggle source
# File lib/geospatial/distance.rb, line 78 def == other @value == other.to_f end
formatted_value()
click to toggle source
# File lib/geospatial/distance.rb, line 40 def formatted_value unless @formatted_value scale = 0 value = @value while value > 1000 and scale < UNITS.size value /= 1000.0 scale += 1 end @formatted_value = sprintf("%0.#{scale}f%s", value, UNITS.fetch(scale)) end return @formatted_value end
Also aliased as: to_s
freeze()
click to toggle source
Calls superclass method
# File lib/geospatial/distance.rb, line 32 def freeze formatted_value super end
to_f()
click to toggle source
# File lib/geospatial/distance.rb, line 58 def to_f @value end