class OrientSupport::MatchConnection

where and while can be composed incremental direction, as, connect and edge cannot be changed after initialisation

Public Class Methods

new(edge= nil, direction: :both, as: nil, count: 1, **args) click to toggle source
# File lib/support/orientquery.rb, line 115
def initialize edge= nil, direction: :both, as: nil, count: 1, **args

  the_edge = edge.is_a?( Class ) ?  edge.ref_name : edge.to_s   unless edge.nil? || edge == E
                    @q =  MatchAttributes.new  the_edge ,  # class
                                                            direction, #              may be :both, :in, :out
                                                            as,                              #      a string
                                                            count,     #      a number
                                                            args[:where],
                                                            args[:while],
                                                            args[:max_depth],
                                                            args[:depth_alias],      # not implemented
                                                            args[:path_alias],       # not implemented
                                                            args[:optional]          # not implemented
end

Public Instance Methods

compose() click to toggle source
# File lib/support/orientquery.rb, line 179
            def compose
                            where_statement =( where.nil? || where.size <5 ) ? nil : "where: ( #{ generate_sql_list( @q[:where] ) })"
                            while_statement =( while_s.nil? || while_s.size <5) ? nil : "while: ( #{ generate_sql_list( @q[:while] )})"
                            
                            ministatement = "{"+ [ as, where_statement, while_statement, max_depth].compact.join(', ') + "}"
                            ministatement = "" if ministatement=="{}"

 (1 .. count).map{|x| direction }.join("") + ministatement

end
Also aliased as: to_s
count(c=nil) click to toggle source
# File lib/support/orientquery.rb, line 160
def count c=nil
        if c
                @q[:count] = c
        else
                @q[:count]
        end
end
direction() click to toggle source
# File lib/support/orientquery.rb, line 135
           def direction
                   fillup =  @q[:edge].present? ? @q[:edge] : ''
                   case @q[:direction]
                   when :both
                           ".both(#{fillup})"
                   when :in
                           ".in(#{fillup})"
                   when :out
                           ".out(#{fillup})"
 when :both_vertex, :bothV
                           ".bothV()"
                   when :out_vertex, :outV
                           ".outV()"
                   when :in_vertex, :inV
                           ".inV()"
when :both_edge, :bothE
                    ".bothE(#{fillup})"
                   when :out_edge, :outE
                           ".outE(#{fillup})"
                   when :in_edge, :outE
                           ".inE(#{fillup})"
                   end

           end
direction=(dir) click to toggle source
# File lib/support/orientquery.rb, line 130
def direction= dir
  @q[:direction] =  dir
end
edge() click to toggle source
# File lib/support/orientquery.rb, line 175
def edge
        @q[:edge]
end
max_depth(d=nil) click to toggle source
# File lib/support/orientquery.rb, line 168
def max_depth d=nil
        if d.nil?
                @q[:max_depth].present? ? "maxDepth: #{@q[:max_depth] }" : nil
        else
                @q[:max_depth] = d
        end
end
to_s()
Alias for: compose