Class: INatGet::Data::Helper::Field::Range Private
- Inherits:
-
INatGet::Data::Helper::Field
- Object
- INatGet::Data::Helper::Field
- INatGet::Data::Helper::Field::Range
- Defined in:
- lib/inat-get/data/helpers/defs/range.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from INatGet::Data::Helper::Field
Instance Method Summary collapse
-
#initialize(helper, key, check) ⇒ Range
constructor
private
A new instance of Range.
- #prepare(value) ⇒ Object private
- #valid?(value) ⇒ Boolean private
Methods inherited from INatGet::Data::Helper::Field
Constructor Details
#initialize(helper, key, check) ⇒ Range
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Range.
7 8 9 10 |
# File 'lib/inat-get/data/helpers/defs/range.rb', line 7 def initialize helper, key, check super helper, key @check = check end |
Instance Method Details
#prepare(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/inat-get/data/helpers/defs/range.rb', line 16 def prepare value case value when nil nil when ::Range value when @check (value .. value) else raise ArgumentError, "Invalid field value: #{ @key } => #{ value.inspect }", caller_locations end end |
#valid?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/inat-get/data/helpers/defs/range.rb', line 12 def valid? value @check === value || (::Range === value && (value.begin.nil? || @check === value.begin) && (value.end.nil? || @check === value.end)) end |