Class: EasyJSONMatcher::NumberValidator
- Defined in:
- lib/easy_json_matcher/number_validator.rb
Instance Attribute Summary
Attributes inherited from Validator
#content, #errors, #key, #required
Instance Method Summary collapse
Methods inherited from Validator
#_check_content_type, #_check_required?, #_create_validator, #_no_errors?, #_post_initialise, #_set_content, #get_errors, #initialize, #reset!, #valid?
Constructor Details
This class inherits a constructor from EasyJSONMatcher::Validator
Instance Method Details
#_content_is_a_number? ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/easy_json_matcher/number_validator.rb', line 11 def _content_is_a_number? begin Kernel::Float(content) true rescue ArgumentError false rescue TypeError false end end |
#_validate ⇒ Object
7 8 9 |
# File 'lib/easy_json_matcher/number_validator.rb', line 7 def _validate errors << "#{content} is not a Number" unless _content_is_a_number? end |