Class: Validation::Rule::Longitude
- Inherits:
-
StretchyRule
- Object
- StretchyRule
- Validation::Rule::Longitude
- Defined in:
- lib/validation/rule/longitude.rb
Instance Method Summary collapse
Methods inherited from StretchyRule
#empty_ok?, #initialize, #invalid_empty?, #is_empty?, #params, #required?
Constructor Details
This class inherits a constructor from Validation::Rule::StretchyRule
Instance Method Details
#error_key ⇒ Object
5 6 7 |
# File 'lib/validation/rule/longitude.rb', line 5 def error_key :longitude end |
#valid_value?(value) ⇒ Boolean
9 10 11 12 13 14 |
# File 'lib/validation/rule/longitude.rb', line 9 def valid_value?(value) valid = true value = Float(value) rescue nil valid = false unless value && value <= 180 && value >= -180 valid end |