Class: OrientSupport::MatchConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/support/orientquery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(edge: nil, direction: :both, as: nil, count: 1) ⇒ MatchConnection

Returns a new instance of MatchConnection.



65
66
67
68
69
70
# File 'lib/support/orientquery.rb', line 65

def initialize edge: nil, direction: :both, as: nil, count: 1
  @edge = edge
  @direction = direction  # may be :both, :in, :out
  @as =  as
  @count =  count
end

Instance Attribute Details

#asObject

Returns the value of attribute as.



64
65
66
# File 'lib/support/orientquery.rb', line 64

def as
  @as
end

Instance Method Details

#composeObject



90
91
92
93
94
# File 'lib/support/orientquery.rb', line 90

def compose
  ministatement = @as.present? ? "{ as: #{@as} } " : "" 
 (1 .. @count).map{|x| direction }.join("{}") << ministatement

end

#directionObject



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/support/orientquery.rb', line 77

def direction
  fillup =  @edge.present? ? @edge : ''
  case @direction
  when :both
  " -#{fillup}- "
  when :in
  " <-#{fillup}- "
  when :out
  " -#{fillup}-> "
  end

end

#direction=(dir) ⇒ Object



72
73
74
# File 'lib/support/orientquery.rb', line 72

def direction= dir
  @direction =  dir
end