Class: Journey::Nodes::Node

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/journey/nodes/node.rb

Overview

:nodoc:

Direct Known Subclasses

Binary, Or, Terminal, Unary

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left) ⇒ Node

Returns a new instance of Node.



10
11
12
13
# File 'lib/journey/nodes/node.rb', line 10

def initialize left
  @left = left
  @memo = nil
end

Instance Attribute Details

#leftObject

Returns the value of attribute left.



8
9
10
# File 'lib/journey/nodes/node.rb', line 8

def left
  @left
end

#memoObject

Returns the value of attribute memo.



8
9
10
# File 'lib/journey/nodes/node.rb', line 8

def memo
  @memo
end

Instance Method Details

#each(&block) ⇒ Object



15
16
17
# File 'lib/journey/nodes/node.rb', line 15

def each(&block)
  Visitors::Each.new(block).accept(self)
end

#literal?Boolean

Returns:

  • (Boolean)


40
# File 'lib/journey/nodes/node.rb', line 40

def literal?; false; end

#nameObject



31
32
33
# File 'lib/journey/nodes/node.rb', line 31

def name
  left.tr ':', ''
end

#symbol?Boolean

Returns:

  • (Boolean)


39
# File 'lib/journey/nodes/node.rb', line 39

def symbol?; false; end

#to_dotObject



23
24
25
# File 'lib/journey/nodes/node.rb', line 23

def to_dot
  Visitors::Dot.new.accept(self)
end

#to_sObject



19
20
21
# File 'lib/journey/nodes/node.rb', line 19

def to_s
  Visitors::String.new.accept(self)
end

#to_symObject



27
28
29
# File 'lib/journey/nodes/node.rb', line 27

def to_sym
  name.to_sym
end

#typeObject

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/journey/nodes/node.rb', line 35

def type
  raise NotImplementedError
end