Class: RubyLint::AST::Node
- Inherits:
-
Parser::AST::Node
- Object
- Parser::AST::Node
- RubyLint::AST::Node
- 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
-
#column ⇒ Numeric
-
#file ⇒ String
-
#inspect_oneline ⇒ String
Similar to
#inspect
but formats the value so that it fits on a single line. -
#line ⇒ Numeric
-
#name ⇒ String
Methods included from VariablePredicates
#constant?, #constant_path?, #ruby_class, #variable?
Instance Method Details
#column ⇒ Numeric
20 21 22 |
# File 'lib/ruby-lint/ast/node.rb', line 20 def column return location.expression.column + 1 if location end |
#file ⇒ String
27 28 29 |
# File 'lib/ruby-lint/ast/node.rb', line 27 def file return location.expression.source_buffer.name if location end |
#inspect_oneline ⇒ String
Similar to #inspect
but formats the value so that it fits on a single
line.
44 45 46 |
# File 'lib/ruby-lint/ast/node.rb', line 44 def inspect_oneline return to_s.gsub(/\s*\n\s*/, ' ') end |
#line ⇒ Numeric
13 14 15 |
# File 'lib/ruby-lint/ast/node.rb', line 13 def line return location.expression.line if location end |
#name ⇒ String
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 |