Method: YARD::Parser::Ruby::AstNode#initialize

Defined in:
lib/yard/parser/ruby/ast_node.rb

#initialize(type, arr, opts = {}) ⇒ AstNode

Creates a new AST node

Parameters:

  • type (Symbol)

    the type of node being created

  • arr (Array<AstNode>)

    the child nodes

  • opts (Hash) (defaults to: {})

    any extra line options

Options Hash (opts):

  • :line (Fixnum) — default: nil

    the line the node starts on in source

  • :char (String) — default: nil

    the character number the node starts on in source

  • :listline (Fixnum) — default: nil

    a special key like :line but for list nodes

  • :listchar (Fixnum) — default: nil

    a special key like :char but for list nodes

  • :token (Boolean) — default: nil

    whether the node represents a token


152
153
154
155
156
157
158
159
160
# File 'lib/yard/parser/ruby/ast_node.rb', line 152

def initialize(type, arr, opts = {})
  super(arr)
  self.type = type
  self.line_range = opts[:line]
  self.source_range = opts[:char]
  @fallback_line = opts[:listline]
  @fallback_source = opts[:listchar]
  @token = true if opts[:token]
end