Sha256: f5a5cb7a0f03aa774901e06a97f56226e76fbe9ac34fc2d819d799ae51ae0788

Contents?: true

Size: 650 Bytes

Versions: 3

Compression:

Stored size: 650 Bytes

Contents

class GeoDistance
  module Conversion
    module Meters
      def in_meters
        convert_to_meters distance
      end
      alias_method :to_meters, :in_meters
      alias_method :as_meters, :in_meters

      def to_meters!
        self.distance = convert_to_meters distance
        self.unit = :meters
        self
      end
      alias_method :in_meters!, :to_meters!
      alias_method :as_meters!, :to_meters!

      def convert_to_meters dist
        (unit == :meters) ? dist : distance / GeoUnits.meters_map[unit]
      end

      def to_meters!
        @distance = in_meters
        @unit = :meters
        self
      end 
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
geo-distance-0.2.2 lib/geo-distance/conversion/meters.rb
geo-distance-0.2.1 lib/geo-distance/conversion/meters.rb
geo-distance-0.2.0 lib/geo-distance/conversion/meters.rb