Class: EasyUpnp::ArgumentValidator::AllowedValueValidator
- Inherits:
-
Object
- Object
- EasyUpnp::ArgumentValidator::AllowedValueValidator
- Defined in:
- lib/easy_upnp/control_point/argument_validator.rb
Instance Attribute Summary collapse
-
#allowed_values ⇒ Object
readonly
Returns the value of attribute allowed_values.
Instance Method Summary collapse
-
#initialize(*allowed_values) ⇒ AllowedValueValidator
constructor
A new instance of AllowedValueValidator.
- #validate(value) ⇒ Object
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_values ⇒ Object (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 |