Class: Cl::Opts::Validate::Validator
- Inherits:
-
Struct
- Object
- Struct
- Cl::Opts::Validate::Validator
- Includes:
- Regex
- Defined in:
- lib/cl/opts/validate.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#orig ⇒ Object
Returns the value of attribute orig.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
Methods included from Regex
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd
14 15 16 |
# File 'lib/cl/opts/validate.rb', line 14 def cmd @cmd end |
#opts ⇒ Object
Returns the value of attribute opts
14 15 16 |
# File 'lib/cl/opts/validate.rb', line 14 def opts @opts end |
#orig ⇒ Object
Returns the value of attribute orig
14 15 16 |
# File 'lib/cl/opts/validate.rb', line 14 def orig @orig end |
#values ⇒ Object
Returns the value of attribute values
14 15 16 |
# File 'lib/cl/opts/validate.rb', line 14 def values @values end |
Instance Method Details
#compact(hash, *keys) ⇒ Object
16 17 18 |
# File 'lib/cl/opts/validate.rb', line 16 def compact(hash, *keys) hash.reject { |_, value| value.nil? }.to_h end |
#invert(hash) ⇒ Object
20 21 22 |
# File 'lib/cl/opts/validate.rb', line 20 def invert(hash) hash.map { |key, obj| Array(obj).map { |obj| [obj, key] } }.flatten(1).to_h end |
#only(hash, *keys) ⇒ Object
24 25 26 |
# File 'lib/cl/opts/validate.rb', line 24 def only(hash, *keys) hash.select { |key, _| keys.include?(key) }.to_h end |