Class: SoftLayer::ObjectFilterOperation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(operator, value) ⇒ ObjectFilterOperation

Returns a new instance of ObjectFilterOperation.

Raises:

  • (ArgumentException)


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

#operatorObject (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

#valueObject (readonly)

The operand of the operator



45
46
47
# File 'lib/softlayer/ObjectFilter.rb', line 45

def value
  @value
end

Instance Method Details

#to_hObject



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