Class: ZOMG::IDL::Nodes::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Visitable

#accept

Constructor Details

#initialize(children = [], options = {}) ⇒ Node

Returns a new instance of Node.



9
10
11
12
# File 'lib/zomg/idl/nodes/node.rb', line 9

def initialize(children = [], options = {})
  @children = children
  options.each { |k,v| send(:"#{k}=", v) }
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



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

def children
  @children
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#duhrObject



18
19
20
# File 'lib/zomg/idl/nodes/node.rb', line 18

def duhr
  Duhr.new(self)
end

#to_iObject



14
15
16
# File 'lib/zomg/idl/nodes/node.rb', line 14

def to_i
  children.to_i
end

#to_ruby(prefix = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/zomg/idl/nodes/node.rb', line 30

def to_ruby(prefix = nil)
  r2r = Ruby2Ruby.new
  ruby_code = r2r.process(to_ruby_sexp)
  if prefix
    modules = prefix.split(/::/).map { |m| "module #{m}\n" }
    ends = modules.map { |m| "end" }.join("\n")
    "#{modules}#{ruby_code}\n#{ends}"
  else
    ruby_code
  end
end

#to_ruby_sexpObject



26
27
28
# File 'lib/zomg/idl/nodes/node.rb', line 26

def to_ruby_sexp
  RubySexp.new.accept(self)
end

#to_sexpObject



22
23
24
# File 'lib/zomg/idl/nodes/node.rb', line 22

def to_sexp
  Sexp.new.accept(self)
end