Class: Neo4j::Core::Cypher::ExprOp
Instance Attribute Summary collapse
Attributes inherited from Expression
#clause, #expressions
Instance Method Summary
collapse
#_add_math_func, #abs, #round, #sign, #sqrt
Methods inherited from Expression
#insert_last, #prefix, #prefixes, #prev_clause
Constructor Details
#initialize(left_expr, right_expr, op, post_fix = "") ⇒ ExprOp
Returns a new instance of ExprOp.
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 872
def initialize(left_expr, right_expr, op, post_fix = "")
super(left_expr.expressions, :where)
@left_expr = left_expr
@right_expr = right_expr
@op = op
@post_fix = post_fix
self.expressions.delete(left_expr)
self.expressions.delete(right_expr)
@left = quote(left_expr)
if regexp?(right_expr)
@op = "=~"
@right = to_regexp(right_expr)
else
@right = right_expr && quote(right_expr)
end
@neg = nil
end
|
Instance Attribute Details
#left ⇒ Object
Returns the value of attribute left.
868
869
870
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 868
def left
@left
end
|
#left_expr ⇒ Object
Returns the value of attribute left_expr.
868
869
870
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 868
def left_expr
@left_expr
end
|
#neg ⇒ Object
Returns the value of attribute neg.
868
869
870
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 868
def neg
@neg
end
|
#op ⇒ Object
Returns the value of attribute op.
868
869
870
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 868
def op
@op
end
|
#post_fix ⇒ Object
Returns the value of attribute post_fix.
868
869
870
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 868
def post_fix
@post_fix
end
|
#right ⇒ Object
Returns the value of attribute right.
868
869
870
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 868
def right
@right
end
|
#right_expr ⇒ Object
Returns the value of attribute right_expr.
868
869
870
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 868
def right_expr
@right_expr
end
|
Instance Method Details
#&(other) ⇒ Object
914
915
916
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 914
def &(other)
ExprOp.new(self, other, "and")
end
|
#-@ ⇒ Object
922
923
924
925
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 922
def -@
@neg = "not"
self
end
|
#binary! ⇒ Object
950
951
952
953
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 950
def binary!
@binary = true
self
end
|
#count ⇒ Object
910
911
912
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 910
def count
ExprOp.new(self, nil, 'count')
end
|
#left_to_s ⇒ Object
942
943
944
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 942
def left_to_s
left.is_a?(ExprOp) ? "(#{left})" : left
end
|
#not ⇒ Object
927
928
929
930
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 927
def not
@neg = "not"
self
end
|
#quote(val) ⇒ Object
894
895
896
897
898
899
900
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 894
def quote(val)
if val.respond_to?(:var_name) && !val.kind_of?(Match)
val.var_name
else
val.is_a?(String) ? %Q["#{val}"] : val
end
end
|
#regexp?(right) ⇒ Boolean
902
903
904
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 902
def regexp?(right)
@op == "=~" || right.is_a?(Regexp)
end
|
#right_to_s ⇒ Object
946
947
948
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 946
def right_to_s
right.is_a?(ExprOp) ? "(#{right})" : right
end
|
#separator ⇒ Object
890
891
892
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 890
def separator
" and "
end
|
#to_regexp(val) ⇒ Object
906
907
908
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 906
def to_regexp(val)
%Q[/#{val.respond_to?(:source) ? val.source : val.to_s}/]
end
|
#to_s ⇒ Object
960
961
962
963
964
965
966
967
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 960
def to_s
if @right
neg ? "#{neg}(#{left_to_s} #{op} #{right_to_s})" : "#{left_to_s} #{op} #{right_to_s}"
else
neg ? "#{neg}#{op}(#{left_to_s}#{post_fix})" : "#{op}(#{left_to_s}#{post_fix})"
end
end
|
#valid? ⇒ Boolean
955
956
957
958
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 955
def valid?
@binary ? @left : @left && @right
end
|
#|(other) ⇒ Object
918
919
920
|
# File 'lib/neo4j-core/cypher/cypher.rb', line 918
def |(other)
ExprOp.new(self, other, "or")
end
|