Class: SoftLayer::ObjectFilterOperation
- Inherits:
-
Object
- Object
- SoftLayer::ObjectFilterOperation
- Defined in:
- lib/softlayer/ObjectFilter.rb
Overview
A class whose instances represent an Object Filter operator and the value it is applied to.
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
The operator, should be a member of the SoftLayer::OBJECT_FILTER_OPERATORS array.
-
#value ⇒ Object
readonly
The operand of the operator.
Instance Method Summary collapse
-
#initialize(operator, value) ⇒ ObjectFilterOperation
constructor
A new instance of ObjectFilterOperation.
- #to_h ⇒ Object
Constructor Details
#initialize(operator, value) ⇒ ObjectFilterOperation
Returns a new instance of ObjectFilterOperation.
47 48 49 50 51 52 53 |
# File 'lib/softlayer/ObjectFilter.rb', line 47 def initialize(operator, value) raise ArgumentException, "An unknown operator was given" if !OBJECT_FILTER_OPERATORS.include?(operator.strip) raise ArgumentException, "Expected a value" if value.nil? || (value.respond_to?(:empty?) && value.empty?) @operator = operator.strip @value = value.strip end |
Instance Attribute Details
#operator ⇒ Object (readonly)
The operator, should be a member of the SoftLayer::OBJECT_FILTER_OPERATORS array
42 43 44 |
# File 'lib/softlayer/ObjectFilter.rb', line 42 def operator @operator end |
#value ⇒ Object (readonly)
The operand of the operator
45 46 47 |
# File 'lib/softlayer/ObjectFilter.rb', line 45 def value @value end |
Instance Method Details
#to_h ⇒ Object
55 56 57 58 59 60 |
# File 'lib/softlayer/ObjectFilter.rb', line 55 def to_h result = ObjectFilter.new result['operation'] = "#{operator} #{value}" result end |