Class: GuidedPath::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/guided_path/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Node

Returns a new instance of Node.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
# File 'lib/guided_path/node.rb', line 8

def initialize(args = {})

  raise(ArgumentError, "Options must be a hash") unless args.kind_of?(Hash)
  args = args.symbolize_keys
  @label = args[:label]

  @next_node = (args[:next_node] || args[:goto])
  @next_node = @next_node.to_s.strip if @next_node

end

Instance Attribute Details

#labelObject

Returns the value of attribute label.



5
6
7
# File 'lib/guided_path/node.rb', line 5

def label
  @label
end

#next_nodeObject

Returns the value of attribute next_node.



6
7
8
# File 'lib/guided_path/node.rb', line 6

def next_node
  @next_node
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
29
30
# File 'lib/guided_path/node.rb', line 23

def to_hash
  output = {}
  if @next_node
    output[:next_node] = @next_node.respond_to?(:label) ? @next_node.label : @next_node.to_s
  end

  output 
end