Module: RubyLint::VariablePredicates
- Included in:
- AST::Node, Definition::ConstantProxy, Definition::RubyObject
- Defined in:
- lib/ruby-lint/variable_predicates.rb
Overview
Module that provides various predicate methods for checking node/definition types.
Constant Summary collapse
- PREDICATE_METHODS =
Array containing various predicate methods to create.
[ :array, :class, :const, :hash, :module, :self, :block, :gvar ]
- RUBY_CLASSES =
Hash containing various Node types and the associated Ruby classes.
{ :str => 'String', :sym => 'Symbol', :int => 'Fixnum', :float => 'Float', :regexp => 'Regexp', :array => 'Array', :hash => 'Hash', :irange => 'Range', :erange => 'Range', :lambda => 'Proc', :true => 'TrueClass', :false => 'FalseClass', :nil => 'NilClass' }
- VARIABLE_TYPES =
List of variable types used in #variable?.
[:lvar, :ivar, :cvar, :gvar]
Instance Method Summary collapse
- #constant? ⇒ TrueClass|FalseClass
- #constant_path? ⇒ TrueClass|FalseClass
- #ruby_class ⇒ String
- #variable? ⇒ TrueClass|FalseClass
Instance Method Details
#constant? ⇒ TrueClass|FalseClass
53 54 55 |
# File 'lib/ruby-lint/variable_predicates.rb', line 53 def constant? return type == :const || type == :module || type == :class end |
#constant_path? ⇒ TrueClass|FalseClass
60 61 62 |
# File 'lib/ruby-lint/variable_predicates.rb', line 60 def constant_path? return constant? && children[0].constant? end |
#ruby_class ⇒ String
67 68 69 |
# File 'lib/ruby-lint/variable_predicates.rb', line 67 def ruby_class return RUBY_CLASSES[type] end |
#variable? ⇒ TrueClass|FalseClass
74 75 76 |
# File 'lib/ruby-lint/variable_predicates.rb', line 74 def variable? return VARIABLE_TYPES.include?(type) end |