Class: Arcade::MatchConnection
- Inherits:
-
Object
- Object
- Arcade::MatchConnection
- Includes:
- Support::Sql
- Defined in:
- lib/match.rb
Overview
where and while can be composed incremental direction, as, connect and edge cannot be changed after initialisation
Instance Method Summary collapse
- #compose ⇒ Object (also: #to_s)
- #count(c = nil) ⇒ Object
- #direction ⇒ Object
- #direction=(dir) ⇒ Object
- #edge ⇒ Object
-
#initialize(edge = nil, direction: :both, as: nil, count: 1, **args) ⇒ MatchConnection
constructor
A new instance of MatchConnection.
- #max_depth(d = nil) ⇒ Object
Methods included from Support::Sql
#compose_where, #generate_sql_list
Constructor Details
#initialize(edge = nil, direction: :both, as: nil, count: 1, **args) ⇒ MatchConnection
Returns a new instance of MatchConnection.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/match.rb', line 13 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 |
Instance Method Details
#compose ⇒ Object Also known as: to_s
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/match.rb', line 77 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 |
#count(c = nil) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/match.rb', line 58 def count c=nil if c @q[:count] = c else @q[:count] end end |
#direction ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/match.rb', line 33 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) ⇒ Object
28 29 30 |
# File 'lib/match.rb', line 28 def direction= dir @q[:direction] = dir end |
#edge ⇒ Object
73 74 75 |
# File 'lib/match.rb', line 73 def edge @q[:edge] end |
#max_depth(d = nil) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/match.rb', line 66 def max_depth d=nil if d.nil? @q[:max_depth].present? ? "maxDepth: #{@q[:max_depth] }" : nil else @q[:max_depth] = d end end |