Class: EasyUpnp::ArgumentValidator::RangeValidator

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(range) ⇒ RangeValidator

Returns a new instance of RangeValidator.



33
34
35
# File 'lib/easy_upnp/control_point/argument_validator.rb', line 33

def initialize(range)
  @range = range
end

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



31
32
33
# File 'lib/easy_upnp/control_point/argument_validator.rb', line 31

def range
  @range
end

Instance Method Details

#validate(value) ⇒ Object



37
38
39
40
41
# File 'lib/easy_upnp/control_point/argument_validator.rb', line 37

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