Class: WebIDL::Ast::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ Node

Returns a new instance of Node.



7
8
9
# File 'lib/webidl/ast/node.rb', line 7

def initialize(parent = nil)
  @parent = parent
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



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

def parent
  @parent
end

Instance Method Details

#accept(visitor, &blk) ⇒ Object



21
22
23
# File 'lib/webidl/ast/node.rb', line 21

def accept(visitor, &blk)
  visitor.send("visit_#{snake_name}", self, &blk)
end

#qualified_nameObject



11
12
13
14
15
16
17
18
19
# File 'lib/webidl/ast/node.rb', line 11

def qualified_name
  return unless @name

  if @parent.respond_to?(:qualified_name)
    "#{@parent.qualified_name}::#{@name}"
  else
    "::#{@name}"
  end
end

#snake_nameObject



25
26
27
# File 'lib/webidl/ast/node.rb', line 25

def snake_name
  self.class.name.split("::").last.snake_case
end