Module: GeoUnits::Methods

Included in:
GeoUnits, GeoUnits
Defined in:
lib/geo_vectors/util/geo_units.rb

Instance Method Summary collapse

Instance Method Details

#check_unit!(unit) ⇒ Object

Raises:

  • (ArgumentError)


24
25
26
# File 'lib/geo_vectors/util/geo_units.rb', line 24

def check_unit! unit
  raise ArgumentError, "Not a valid unit" if !valid_unit? unit
end

#default_unitObject

The default unit is assumed to be kms This can be changed Example:

GeoVector.default_unit = :km


16
17
18
# File 'lib/geo_vectors/util/geo_units.rb', line 16

def default_unit
  @default_unit || :kms
end

#default_unit=(unit) ⇒ Object



20
21
22
# File 'lib/geo_vectors/util/geo_units.rb', line 20

def default_unit= unit
  @default_unit || :kms
end

#valid_unit?(unit) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/geo_vectors/util/geo_units.rb', line 7

def valid_unit? unit
  valid_units.include? unit
end

#valid_unitsObject



3
4
5
# File 'lib/geo_vectors/util/geo_units.rb', line 3

def valid_units
  [:feet, :meters, :kms, :miles, :radians]
end