Class: INatGet::Data::Helper::Field::Set Private
- Inherits:
-
INatGet::Data::Helper::Field
- Object
- INatGet::Data::Helper::Field
- INatGet::Data::Helper::Field::Set
- Defined in:
- lib/inat-get/data/helpers/defs/set.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.
Instance Attribute Summary
Attributes inherited from INatGet::Data::Helper::Field
Instance Method Summary collapse
-
#initialize(helper, key, check) ⇒ Set
constructor
private
A new instance of Set.
- #prepare(value) ⇒ Object private
- #valid?(value) ⇒ Boolean private
Methods inherited from INatGet::Data::Helper::Field
Constructor Details
#initialize(helper, key, check) ⇒ Set
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 Set.
9 10 11 12 |
# File 'lib/inat-get/data/helpers/defs/set.rb', line 9 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.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/inat-get/data/helpers/defs/set.rb', line 27 def prepare value case value when nil nil when Enumerable value.to_set when @check ::Set[ 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.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/inat-get/data/helpers/defs/set.rb', line 14 def valid? value return true if value.nil? return true if @check === value if value.is_a?(Enumerable) value.each do |v| next if @check === v return false end return true end return false end |