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
- 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', :dstr => '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
54 55 56 |
# File 'lib/ruby-lint/variable_predicates.rb', line 54 def constant? return type == :const || type == :module || type == :class end |
#constant_path? ⇒ TrueClass|FalseClass
61 62 63 |
# File 'lib/ruby-lint/variable_predicates.rb', line 61 def constant_path? return constant? && children[0].constant? end |
#ruby_class ⇒ String
68 69 70 |
# File 'lib/ruby-lint/variable_predicates.rb', line 68 def ruby_class return RUBY_CLASSES[type] end |
#variable? ⇒ TrueClass|FalseClass
75 76 77 |
# File 'lib/ruby-lint/variable_predicates.rb', line 75 def variable? return VARIABLE_TYPES.include?(type) end |