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.



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

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

#operand ⇒ Object (readonly)

Returns the value of attribute operand.



3
4
5
# File 'lib/graphoid/queries/operation.rb', line 3

def operand
  @operand
end

#operator ⇒ Object (readonly)

Returns the value of attribute operator.



3
4
5
# File 'lib/graphoid/queries/operation.rb', line 3

def operator
  @operator
end

#scope ⇒ Object (readonly)

Returns the value of attribute scope.



3
4
5
# File 'lib/graphoid/queries/operation.rb', line 3

def scope
  @scope
end

#value ⇒ Object (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/graphoid/queries/operation.rb', line 3

def value
  @value
end

Instance Method Details

#resolve ⇒ Object



16
17
18
# File 'lib/graphoid/queries/operation.rb', line 16

def resolve
  @operand.resolve(self)
end