Class: Magiq::Types::Longitude

Inherits:
Type
  • Object
show all
Defined in:
lib/magiq/types.rb

Instance Attribute Summary

Attributes inherited from Type

#raw

Instance Method Summary collapse

Methods inherited from Type

cast, #initialize

Constructor Details

This class inherits a constructor from Magiq::Types::Type

Instance Method Details

#cast!Object



160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/magiq/types.rb', line 160

def cast!
  case v = raw.to_f
  when 0.0
    bad! "provided value of #{raw.inspect} is not permitted, it must " \
    "be a valid longitude within -180.0 to 180.0"
  when -180..180
    v
  else
    bad! "provided value of #{raw.inspect} is not permitted, it must " \
    "be a valid longitude within -180.0 to 180.0"
  end
end