Class: Parser::AST::Node

Inherits:
AST::Node
  • Object
show all
Defined in:
lib/parser/ast/node.rb

Overview

Node contains information about a single AST node and its child nodes. It extends the basic [AST::Node](rdoc.info/gems/ast/AST/Node) class provided by gem [ast](rdoc.info/gems/ast).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#locationParser::Source::Map (readonly) Also known as: loc

Source map for this Node.

Returns:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/parser/ast/node.rb', line 17

class Node < ::AST::Node
  attr_reader :location

  alias loc location

  ##
  # Assigns various properties to this AST node. Currently only the
  # location can be set.
  #
  # @param [Hash] properties
  # @option properties [Parser::Source::Map] :location Location information
  #  of the node.
  #
  def assign_properties(properties)
    if (location = properties[:location])
      location = location.dup if location.frozen?
      location.node = self
      @location = location
    end
  end
end

Instance Method Details

#assign_properties(properties) ⇒ Object

Assigns various properties to this AST node. Currently only the location can be set.

Parameters:

  • properties (Hash)

Options Hash (properties):


30
31
32
33
34
35
36
# File 'lib/parser/ast/node.rb', line 30

def assign_properties(properties)
  if (location = properties[:location])
    location = location.dup if location.frozen?
    location.node = self
    @location = location
  end
end