Class: Mementus::Query::Traversal

Inherits:
Object
  • Object
show all
Defined in:
lib/mementus/query/traversal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph) ⇒ Traversal

Returns a new instance of Traversal.



6
7
8
9
# File 'lib/mementus/query/traversal.rb', line 6

def initialize(graph)
  @graph = graph
  @steps = []
end

Instance Attribute Details

#graphObject (readonly)

Returns the value of attribute graph.



4
5
6
# File 'lib/mementus/query/traversal.rb', line 4

def graph
  @graph
end

Instance Method Details

#add_step(step) ⇒ Object



11
12
13
14
# File 'lib/mementus/query/traversal.rb', line 11

def add_step(step)
  @steps << step
  self
end

#adjacentObject



16
17
18
# File 'lib/mementus/query/traversal.rb', line 16

def adjacent
  @steps.last.to_node.adjacent
end

#idObject



20
21
22
# File 'lib/mementus/query/traversal.rb', line 20

def id
  @steps.last.to_node.id
end