Class: EasyUpnp::ArgumentValidator::AllowedValueValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_upnp/control_point/argument_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*allowed_values) ⇒ AllowedValueValidator

Returns a new instance of AllowedValueValidator.



47
48
49
# File 'lib/easy_upnp/control_point/argument_validator.rb', line 47

def initialize(*allowed_values)
  @allowed_values = allowed_values
end

Instance Attribute Details

#allowed_valuesObject (readonly)

Returns the value of attribute allowed_values.



45
46
47
# File 'lib/easy_upnp/control_point/argument_validator.rb', line 45

def allowed_values
  @allowed_values
end

Instance Method Details

#validate(value) ⇒ Object



51
52
53
54
55
# File 'lib/easy_upnp/control_point/argument_validator.rb', line 51

def validate(value)
  if !@allowed_values.include?(value)
    raise ArgumentError, "#{value} is not in list of allowed values: #{@allowed_values.inspect}"
  end
end