Class: InterMine::PathQuery::LogicGroup

Inherits:
LogicNode
  • Object
show all
Defined in:
lib/intermine/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, op, right, parent = nil) ⇒ LogicGroup

Returns a new instance of LogicGroup.



1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
# File 'lib/intermine/query.rb', line 1322

def initialize(left, op, right, parent=nil)
    if !["AND", "OR"].include?(op)
        raise ArgumentError, "#{op} is not a legal logical operator"
    end
    @parent = parent
    @left = left
    @op = op
    @right = right
    [left, right].each do |node|
        if node.is_a?(LogicGroup)
            node.parent = self
        end
    end
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



1319
1320
1321
# File 'lib/intermine/query.rb', line 1319

def left
  @left
end

#opObject (readonly)

Returns the value of attribute op.



1319
1320
1321
# File 'lib/intermine/query.rb', line 1319

def op
  @op
end

#parentObject

Returns the value of attribute parent.



1320
1321
1322
# File 'lib/intermine/query.rb', line 1320

def parent
  @parent
end

#rightObject (readonly)

Returns the value of attribute right.



1319
1320
1321
# File 'lib/intermine/query.rb', line 1319

def right
  @right
end

Instance Method Details

#codeObject



1346
1347
1348
# File 'lib/intermine/query.rb', line 1346

def code
    return to_s
end

#to_sObject



1337
1338
1339
1340
1341
1342
1343
1344
# File 'lib/intermine/query.rb', line 1337

def to_s
    core = [@left.code, @op.downcase, @right.code].join(" ")
    if @parent && @op != @parent.op
        return "(#{core})"
    else
        return core
    end
end