Module: GeoUnits::Methods
Instance Method Summary collapse
- #check_unit!(unit) ⇒ Object
-
#default_unit ⇒ Object
The default unit is assumed to be kms This can be changed Example: GeoVector.default_unit = :km.
- #default_unit=(unit) ⇒ Object
- #valid_unit?(unit) ⇒ Boolean
- #valid_units ⇒ Object
Instance Method Details
#check_unit!(unit) ⇒ Object
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_unit ⇒ Object
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
7 8 9 |
# File 'lib/geo_vectors/util/geo_units.rb', line 7 def valid_unit? unit valid_units.include? unit end |
#valid_units ⇒ Object
3 4 5 |
# File 'lib/geo_vectors/util/geo_units.rb', line 3 def valid_units [:feet, :meters, :kms, :miles, :radians] end |