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



1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
# File 'lib/intermine/query.rb', line 1418

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.



1415
1416
1417
# File 'lib/intermine/query.rb', line 1415

def left
  @left
end

#opObject (readonly)

Returns the value of attribute op.



1415
1416
1417
# File 'lib/intermine/query.rb', line 1415

def op
  @op
end

#parentObject

Returns the value of attribute parent.



1416
1417
1418
# File 'lib/intermine/query.rb', line 1416

def parent
  @parent
end

#rightObject (readonly)

Returns the value of attribute right.



1415
1416
1417
# File 'lib/intermine/query.rb', line 1415

def right
  @right
end

Instance Method Details

#codeObject



1442
1443
1444
# File 'lib/intermine/query.rb', line 1442

def code
    return to_s
end

#to_sObject



1433
1434
1435
1436
1437
1438
1439
1440
# File 'lib/intermine/query.rb', line 1433

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