Class: Humidifier::Props::ListProp
Constant Summary
Constants inherited from Prop
Instance Attribute Summary collapse
-
#subprop ⇒ Object
readonly
Returns the value of attribute subprop.
Attributes inherited from Prop
Instance Method Summary collapse
-
#initialize(key, spec = {}, substructs = {}) ⇒ ListProp
constructor
A new instance of ListProp.
- #to_cf(list) ⇒ Object
- #valid?(list) ⇒ Boolean
Methods inherited from Prop
allow_type, allowed_types, #documentation, #required?, #update_type
Constructor Details
#initialize(key, spec = {}, substructs = {}) ⇒ ListProp
Returns a new instance of ListProp.
83 84 85 86 |
# File 'lib/humidifier/props.rb', line 83 def initialize(key, spec = {}, substructs = {}) super(key, spec) @subprop = Props.singular_from(key, spec, substructs) end |
Instance Attribute Details
#subprop ⇒ Object (readonly)
Returns the value of attribute subprop
81 82 83 |
# File 'lib/humidifier/props.rb', line 81 def subprop @subprop end |
Instance Method Details
#to_cf(list) ⇒ Object
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/humidifier/props.rb', line 88 def to_cf(list) cf_value = if list.respond_to?(:to_cf) list.to_cf else list.map { |value| subprop.to_cf(value).last } end [key, cf_value] end |
#valid?(list) ⇒ Boolean
99 100 101 102 103 |
# File 'lib/humidifier/props.rb', line 99 def valid?(list) return true if super(list) list.is_a?(Enumerable) && list.all? { |value| subprop.valid?(value) } end |