Class: Graphoid::Operation

Inherits:
Object
  • Object
show all
Defined in:
lib/graphoid/queries/operation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, key, value) ⇒ Operation

Returns a new instance of Operation.



7
8
9
10
11
12
13
14
15
16
# File 'lib/graphoid/queries/operation.rb', line 7

def initialize(scope, key, value)
  @scope = scope
  @operator = nil
  @operand = key
  @value = value

  match = key.match(/^(.+)_(.+)$/)
  @operand, @operator = match[1..2] if match
  @operand = build_operand(@scope, @operand) || @operand
end

Instance Attribute Details

#operandObject (readonly)

Returns the value of attribute operand.



5
6
7
# File 'lib/graphoid/queries/operation.rb', line 5

def operand
  @operand
end

#operatorObject (readonly)

Returns the value of attribute operator.



5
6
7
# File 'lib/graphoid/queries/operation.rb', line 5

def operator
  @operator
end

#scopeObject (readonly)

Returns the value of attribute scope.



5
6
7
# File 'lib/graphoid/queries/operation.rb', line 5

def scope
  @scope
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/graphoid/queries/operation.rb', line 5

def value
  @value
end

Instance Method Details

#resolveObject



18
19
20
# File 'lib/graphoid/queries/operation.rb', line 18

def resolve
  @operand.resolve(self)
end