Class: ArangoTraversal
- Inherits:
-
ArangoServer
- Object
- ArangoServer
- ArangoTraversal
- Defined in:
- lib/ArangoRB_Tra.rb
Overview
TRAVERSAL ===
Instance Attribute Summary collapse
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#expander ⇒ Object
Returns the value of attribute expander.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#idCache ⇒ Object
readonly
Returns the value of attribute idCache.
-
#init ⇒ Object
Returns the value of attribute init.
-
#itemOrder ⇒ Object
Returns the value of attribute itemOrder.
-
#maxDepth ⇒ Object
(also: #max)
Returns the value of attribute maxDepth.
-
#maxiterations ⇒ Object
Returns the value of attribute maxiterations.
-
#minDepth ⇒ Object
(also: #min)
Returns the value of attribute minDepth.
-
#order ⇒ Object
Returns the value of attribute order.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#sort ⇒ Object
Returns the value of attribute sort.
-
#strategy ⇒ Object
Returns the value of attribute strategy.
-
#uniqueness ⇒ Object
Returns the value of attribute uniqueness.
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
-
#visitor ⇒ Object
Returns the value of attribute visitor.
Instance Method Summary collapse
-
#any ⇒ Object
TESTED.
- #database ⇒ Object
- #edgeCollection ⇒ Object (also: #collection)
-
#edgeCollection=(edgeCollection) ⇒ Object
(also: #collection=)
TESTED.
-
#execute ⇒ Object
TESTED.
- #graphName ⇒ Object (also: #graph)
-
#graphName=(graphName) ⇒ Object
(also: #graph=)
TESTED.
-
#in ⇒ Object
TESTED.
-
#initialize(body: {}, database: @@database, graph: nil, edgeCollection: nil) ⇒ ArangoTraversal
constructor
TESTED.
-
#out ⇒ Object
TESTED.
- #startVertex ⇒ Object (also: #vertex)
-
#startVertex=(startVertex) ⇒ Object
(also: #vertex=)
TESTED.
-
#to_hash ⇒ Object
(also: #to_h)
RETRIEVE ###.
Methods inherited from ArangoServer
address, async, async=, batch, cancelAsync, changePropertyWAL, checkPort, cluster, cluster=, clusterRoundtrip, clusterStatistics, collection, collection=, createDumpBatch, database, database=, databaseVersion, databases, default_server, destroyAllAsync, destroyAsync, destroyCluster, destroyDumpBatch, destroyExpiredAsync, echo, endpoints, execute, executeCluster, executeClusterHead, executeClusterPut, fetchAsync, flushWAL, graph, graph=, log, pendingAsync, prolongDumpBatch, propertyWAL, reload, request, restart, retrieveAsync, retrieveDoneAsync, retrievePendingAsync, return_result, return_result_async, role, server, serverId, shutdown, sleep, statistics, tasks, test, time, transactions, updateCluster, user, user=, username, users, verbose, verbose=, version
Constructor Details
#initialize(body: {}, database: @@database, graph: nil, edgeCollection: nil) ⇒ ArangoTraversal
TESTED
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ArangoRB_Tra.rb', line 4 def initialize(body: {}, database: @@database, graph: nil, edgeCollection: nil) # TESTED @sort = body["sort"] @direction = body["direction"] @maxDepth = body["maxDepth"] @minDepth = body["minDepth"] @startVertex = body["startVertex"] @visitor = body["visitor"] @itemOrder = body["itemOrder"] @strategy = body["strategy"] @filter = body["filter"] @init = body["init"] @maxiterations = body["maxiterations"] @uniqueness = body["uniqueness"] @order = body["order"] @graphName = body["graphName"].nil? ? graph : body["graphName"] @expander = body["expander"] @edgeCollection = body["edgeCollection"].nil? ? edgeCollection : body["edgeCollection"] @database = database @vertices = nil @paths = nil @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def direction @direction end |
#expander ⇒ Object
Returns the value of attribute expander.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def @expander end |
#filter ⇒ Object
Returns the value of attribute filter.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def filter @filter end |
#idCache ⇒ Object (readonly)
Returns the value of attribute idCache.
28 29 30 |
# File 'lib/ArangoRB_Tra.rb', line 28 def idCache @idCache end |
#init ⇒ Object
Returns the value of attribute init.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def init @init end |
#itemOrder ⇒ Object
Returns the value of attribute itemOrder.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def itemOrder @itemOrder end |
#maxDepth ⇒ Object Also known as: max
Returns the value of attribute maxDepth.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def maxDepth @maxDepth end |
#maxiterations ⇒ Object
Returns the value of attribute maxiterations.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def maxiterations @maxiterations end |
#minDepth ⇒ Object Also known as: min
Returns the value of attribute minDepth.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def minDepth @minDepth end |
#order ⇒ Object
Returns the value of attribute order.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def order @order end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
28 29 30 |
# File 'lib/ArangoRB_Tra.rb', line 28 def paths @paths end |
#sort ⇒ Object
Returns the value of attribute sort.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def sort @sort end |
#strategy ⇒ Object
Returns the value of attribute strategy.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def strategy @strategy end |
#uniqueness ⇒ Object
Returns the value of attribute uniqueness.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def uniqueness @uniqueness end |
#vertices ⇒ Object (readonly)
Returns the value of attribute vertices.
28 29 30 |
# File 'lib/ArangoRB_Tra.rb', line 28 def vertices @vertices end |
#visitor ⇒ Object
Returns the value of attribute visitor.
27 28 29 |
# File 'lib/ArangoRB_Tra.rb', line 27 def visitor @visitor end |
Instance Method Details
#any ⇒ Object
TESTED
118 119 120 121 |
# File 'lib/ArangoRB_Tra.rb', line 118 def any # TESTED @direction = "any" @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") end |
#database ⇒ Object
67 68 69 |
# File 'lib/ArangoRB_Tra.rb', line 67 def database ArangoDatabase.new(database: @database) end |
#edgeCollection ⇒ Object Also known as: collection
63 64 65 |
# File 'lib/ArangoRB_Tra.rb', line 63 def edgeCollection ArangoCollection.new(collection: @edgeCollection, database: @database) end |
#edgeCollection=(edgeCollection) ⇒ Object Also known as: collection=
TESTED
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ArangoRB_Tra.rb', line 97 def edgeCollection=(edgeCollection) # TESTED if edgeCollection.is_a?(String) || edgeCollection.nil? @edgeCollection = edgeCollection elsif edgeCollection.is_a?(ArangoCollection) @edgeCollection = edgeCollection.collection else raise "edgeCollection should be a String or an ArangoCollection instance, not a #{edgeCollection.class}" end @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") end |
#execute ⇒ Object
TESTED
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/ArangoRB_Tra.rb', line 134 def execute # TESTED body = { "sort" => @sort, "direction" => @direction, "maxDepth" => @maxDepth, "minDepth" => @minDepth, "startVertex" => @startVertex, "visitor" => @visitor, "itemOrder" => @itemOrder, "strategy" => @strategy, "filter" => @filter, "init" => @init, "maxiterations" => @maxiterations, "uniqueness" => @uniqueness, "order" => @order, "graphName" => @graphName, "expander" => @expander, "edgeCollection" => @edgeCollection }.delete_if{|k,v| v.nil?} request = @@request.merge({ :body => body.to_json }) result = self.class.post("/_db/#{@database}/_api/traversal", request) return result.headers["x-arango-async-id"] if @@async == "store" return true if @@async result = result.parsed_response return @@verbose ? result : result["errorMessage"] if result["error"] @vertices = result["result"]["visited"]["vertices"].map{|x| ArangoDocument.new(key: x["_key"], collection: x["_id"].split("/")[0], database: @database, body: x)} @paths = result["result"]["visited"]["paths"].map{|x| { "edges" => x["edges"].map{|e| ArangoDocument.new(key: e["_key"], collection: e["_id"].split("/")[0], database: @database, body: e, from: e["_from"], to: e["_to"] )}, "vertices" => x["vertices"].map{|v| ArangoDocument.new(key: v["_key"], collection: v["_id"].split("/")[0], database: @database, body: v )} } } @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") @@verbose ? result : self end |
#graphName ⇒ Object Also known as: graph
71 72 73 |
# File 'lib/ArangoRB_Tra.rb', line 71 def graphName ArangoGraph.new(graph: @graphName, database: @database).retrieve end |
#graphName=(graphName) ⇒ Object Also known as: graph=
TESTED
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ArangoRB_Tra.rb', line 86 def graphName=(graphName) # TESTED if graphName.is_a?(String) || graphName.nil? @graphName = graphName elsif graphName.is_a?(ArangoGraph) @graphName = graphName.graph else raise "graphName should be a String or an ArangoGraph instance, not a #{graphName.class}" end @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") end |
#in ⇒ Object
TESTED
108 109 110 111 |
# File 'lib/ArangoRB_Tra.rb', line 108 def in # TESTED @direction = "inbound" @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") end |
#out ⇒ Object
TESTED
113 114 115 116 |
# File 'lib/ArangoRB_Tra.rb', line 113 def out # TESTED @direction = "outbound" @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") end |
#startVertex ⇒ Object Also known as: vertex
58 59 60 61 |
# File 'lib/ArangoRB_Tra.rb', line 58 def startVertex val = @startVertex.split("/") ArangoDocument.new(database: @database, collection: val[0], key: val[1]) end |
#startVertex=(startVertex) ⇒ Object Also known as: vertex=
TESTED
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ArangoRB_Tra.rb', line 75 def startVertex=(startVertex) # TESTED if startVertex.is_a?(String) @startVertex = startVertex elsif startVertex.is_a?(ArangoDocument) @startVertex = startVertex.id else raise "startVertex should be a String or an ArangoDocument instance, not a #{startVertex.class}" end @idCache = "ATR_#{@database}_#{@direction}_#{@startVertex}_" + (@graphName.nil? ? "#{@edgeCollection}" : "#{@graphName}") end |
#to_hash ⇒ Object Also known as: to_h
RETRIEVE ###
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ArangoRB_Tra.rb', line 32 def to_hash { "database" => @database, "sort" => @sort, "direction" => @direction, "maxDepth" => @maxDepth, "minDepth" => @minDepth, "startVertex" => @startVertex, "visitor" => @visitor, "itemOrder" => @itemOrder, "strategy" => @strategy, "filter" => @filter, "init" => @init, "maxiterations" => @maxiterations, "uniqueness" => @uniqueness, "order" => @order, "graphName" => @graphName, "expander" => @expander, "edgeCollection" => @edgeCollection, "vertices" => @vertices.map{|x| x.id}, "paths" => @paths.map{|x| {"edges" => x["edges"].map{|e| e.id}, "vertices" => x["vertices"].map{|v| v.id} } }, "idCache" => @idCache }.delete_if{|k,v| v.nil?} end |