class Neography::PathTraverser
Attributes
algorithm[RW]
depth[RW]
get[RW]
relationships[RW]
rels[RW]
Public Class Methods
new(from, to, algorithm, all=false, types = nil, dir = "all" )
click to toggle source
# File lib/neography/path_traverser.rb, line 7 def initialize(from, to, algorithm, all=false, types = nil, dir = "all" ) @from = from @to = to @algorithm = algorithm @all = all @relationships = Array.new types.each do |type| @relationships << {"type" => type.to_s, "direction" => dir.to_s } end unless types.nil? @get = ["node","rel"] @loaded_nodes = Array.new @loaded_rels = Array.new end
Public Instance Methods
both(type)
click to toggle source
# File lib/neography/path_traverser.rb, line 33 def both(type) @relationships << {"type" => type.to_s, "direction" => "all"} self end
each() { |compact| ... }
click to toggle source
# File lib/neography/path_traverser.rb, line 60 def each iterator.each do |path| paths = Array.new if @get.include?("node") path["nodes"].each_with_index do |n, i| @loaded_nodes[get_id(n)] = Neography::Node.load(n) if @loaded_nodes.at(get_id(n)).nil? paths[i * 2] = @loaded_nodes[get_id(n)] end end if @get.include?("rel") path["relationships"].each_with_index do |r, i| @loaded_rels[get_id(r)] = Neography::Relationship.load(r) if @loaded_rels.at(get_id(r)).nil? paths[i * 2 + 1] = @loaded_rels[get_id(r)] end end yield paths.compact end end
empty?()
click to toggle source
# File lib/neography/path_traverser.rb, line 82 def empty? first == nil end
incoming(type)
click to toggle source
# File lib/neography/path_traverser.rb, line 43 def incoming(type) @relationships << {"type" => type.to_s, "direction" => "in"} self end
iterator()
click to toggle source
# File lib/neography/path_traverser.rb, line 86 def iterator if @all.nil? @from.neo_server.get_path(@from, @to, @relationships, @depth, @algorithm) else @from.neo_server.get_paths(@from, @to, @relationships, @depth, @algorithm) end end
nodes()
click to toggle source
# File lib/neography/path_traverser.rb, line 21 def nodes @get = ["node"] self end
outgoing(type)
click to toggle source
# File lib/neography/path_traverser.rb, line 38 def outgoing(type) @relationships << {"type" => type.to_s, "direction" => "out"} self end
size()
click to toggle source
# File lib/neography/path_traverser.rb, line 54 def size [*self].size end
Also aliased as: length
Private Instance Methods
get_id(object)
click to toggle source
# File lib/neography/path_traverser.rb, line 95 def get_id(object) object.split('/').last.to_i end