Class: Reek::Source::AstNode

Inherits:
Parser::AST::Node
  • Object
show all
Defined in:
lib/reek/source/ast_node.rb

Overview

Base class for AST nodes extended with utility methods. Contains some methods to ease the transition from Sexp to AST::Node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of AstNode


10
11
12
13
# File 'lib/reek/source/ast_node.rb', line 10

def initialize(type, children = [], options = {})
  @comments = options.fetch(:comments, [])
  super
end

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments


8
9
10
# File 'lib/reek/source/ast_node.rb', line 8

def comments
  @comments
end

Instance Method Details

#[](index) ⇒ Object

Deprecated.

20
21
22
# File 'lib/reek/source/ast_node.rb', line 20

def [](index)
  elements[index]
end

#firstObject

Deprecated.

29
30
31
# File 'lib/reek/source/ast_node.rb', line 29

def first
  type
end

#lineObject


24
25
26
# File 'lib/reek/source/ast_node.rb', line 24

def line
  loc.line
end