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.


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

def initialize edge: nil, direction: :both, as: nil, count: 1
  @edge = edge.is_a?( Class ) ?  edge.ref_name : edge.to_s
  @direction = direction  # may be :both, :in, :out
  @as =  as
  @count =  count
end

Instance Attribute Details

#asObject

Returns the value of attribute as


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

def as
  @as
end

Instance Method Details

#composeObject


94
95
96
97
98
# File 'lib/support/orientquery.rb', line 94

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

end

#directionObject


81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/support/orientquery.rb', line 81

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

end

#direction=(dir) ⇒ Object


76
77
78
# File 'lib/support/orientquery.rb', line 76

def direction= dir
  @direction =  dir
end