Class: Johnson::Nodes::Node

Inherits:
Object
  • Object
show all
Includes:
Visitable, Visitors
Defined in:
lib/johnson/nodes/node.rb

Direct Known Subclasses

BinaryNode, For, ForIn, Function, List, TernaryNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Visitable

#accept

Constructor Details

#initialize(line, column, value) ⇒ Node

Returns a new instance of Node.



35
36
37
38
39
# File 'lib/johnson/nodes/node.rb', line 35

def initialize(line, column, value)
  @line = line
  @column = column
  @value = value
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



34
35
36
# File 'lib/johnson/nodes/node.rb', line 34

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line.



34
35
36
# File 'lib/johnson/nodes/node.rb', line 34

def line
  @line
end

#valueObject

Returns the value of attribute value.



33
34
35
# File 'lib/johnson/nodes/node.rb', line 33

def value
  @value
end

Instance Method Details

#each(&block) ⇒ Object



61
62
63
64
# File 'lib/johnson/nodes/node.rb', line 61

def each(&block)
  EnumeratingVisitor.new(block).accept(self)
  self
end

#to_dotObject



57
58
59
# File 'lib/johnson/nodes/node.rb', line 57

def to_dot
  DotVisitor.new { |d| d.accept(self) }
end

#to_ecmaObject Also known as: to_js



51
52
53
# File 'lib/johnson/nodes/node.rb', line 51

def to_ecma
  EcmaVisitor.new.accept(self)
end

#to_sObject Also known as: inspect



41
42
43
# File 'lib/johnson/nodes/node.rb', line 41

def to_s
  to_sexp.inspect
end

#to_sexpObject



47
48
49
# File 'lib/johnson/nodes/node.rb', line 47

def to_sexp
  SexpVisitor.new.accept(self)
end