class Humidifier::Props::ListProp

Attributes

subprop[R]

Public Class Methods

new(key, spec = {}, subprop = nil) click to toggle source
Calls superclass method Humidifier::Props::Prop::new
# File lib/humidifier/props.rb, line 107
def initialize(key, spec = {}, subprop = nil)
  super(key, spec)
  @subprop = subprop
end

Public Instance Methods

pretty_print(q) click to toggle source
# File lib/humidifier/props.rb, line 112
def pretty_print(q)
  q.group do
    q.text("(#{name}=list")
    q.nest(2) do
      q.breakable
      q.pp(subprop)
    end
    q.breakable("")
    q.text(")")
  end
end
to_cf(list) click to toggle source
# File lib/humidifier/props.rb, line 124
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) click to toggle source
Calls superclass method Humidifier::Props::Prop#valid?
# File lib/humidifier/props.rb, line 135
def valid?(list)
  return true if super(list)

  list.is_a?(Enumerable) && list.all? { |value| subprop.valid?(value) }
end