Class: RubyLint::AST::Node

Inherits:
Parser::AST::Node
  • Object
show all
Includes:
VariablePredicates
Defined in:
lib/ruby-lint/ast/node.rb

Overview

Extends the Node class provided by the parser Gem with various extra methods.

Constant Summary

Constants included from VariablePredicates

VariablePredicates::PREDICATE_METHODS, VariablePredicates::RUBY_CLASSES, VariablePredicates::VARIABLE_TYPES

Instance Method Summary collapse

Methods included from VariablePredicates

#constant?, #constant_path?, #ruby_class, #variable?

Instance Method Details

#columnNumeric

Returns:

  • (Numeric)


20
21
22
# File 'lib/ruby-lint/ast/node.rb', line 20

def column
  return location.expression.column + 1 if location
end

#fileString

Returns:



27
28
29
# File 'lib/ruby-lint/ast/node.rb', line 27

def file
  return location.expression.source_buffer.name if location
end

#inspect_onelineString

Similar to #inspect but formats the value so that it fits on a single line.

Returns:



44
45
46
# File 'lib/ruby-lint/ast/node.rb', line 44

def inspect_oneline
  return to_s.gsub(/\s*\n\s*/, ' ')
end

#lineNumeric

Returns:

  • (Numeric)


13
14
15
# File 'lib/ruby-lint/ast/node.rb', line 13

def line
  return location.expression.line if location
end

#nameString

Returns:



34
35
36
# File 'lib/ruby-lint/ast/node.rb', line 34

def name
  return const? ? children[-1].to_s : children[0].to_s
end