Class: Payload::ARMFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/payload/arm/attr.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attr, val) ⇒ ARMFilter

Returns a new instance of ARMFilter.



7
8
9
10
11
# File 'lib/payload/arm/attr.rb', line 7

def initialize(attr, val)
  @attr = attr.to_s
  @val = val
  @opval = self.class.op + val.to_s
end

Instance Attribute Details

#attrObject (readonly)

Returns the value of attribute attr.



5
6
7
# File 'lib/payload/arm/attr.rb', line 5

def attr
  @attr
end

#opvalObject (readonly)

Returns the value of attribute opval.



5
6
7
# File 'lib/payload/arm/attr.rb', line 5

def opval
  @opval
end

#valObject (readonly)

Returns the value of attribute val.



5
6
7
# File 'lib/payload/arm/attr.rb', line 5

def val
  @val
end

Class Method Details

.opObject



13
14
15
# File 'lib/payload/arm/attr.rb', line 13

def self.op
  ''
end

Instance Method Details

#|(other) ⇒ Object

Raises:

  • (TypeError)


17
18
19
20
21
22
# File 'lib/payload/arm/attr.rb', line 17

def |(other)
  raise TypeError, 'invalid type' unless other.is_a?(Payload::ARMFilter)
  raise ArgumentError, '`or` only works on the same attribute' if other.attr != @attr
  joined = [@opval, other.opval].join('|')
  Payload::ARMEqual.new(@attr, joined)
end