Class: RuboCop::Cop::Lint::DeprecatedClassMethods::DeprecatedClassMethod

Inherits:
Object
  • Object
show all
Includes:
AST::Sexp
Defined in:
lib/rubocop/cop/lint/deprecated_class_methods.rb

Overview

Inner class to DeprecatedClassMethods. This class exists to add abstraction and clean naming to the deprecated objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, class_constant: nil, correctable: true) ⇒ DeprecatedClassMethod

Returns a new instance of DeprecatedClassMethod.


38
39
40
41
42
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 38

def initialize(method, class_constant: nil, correctable: true)
  @method = method
  @class_constant = class_constant
  @correctable = correctable
end

Instance Attribute Details

#class_constantObject (readonly)

Returns the value of attribute class_constant.


36
37
38
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 36

def class_constant
  @class_constant
end

#methodObject (readonly)

Returns the value of attribute method.


36
37
38
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 36

def method
  @method
end

Instance Method Details

#class_nodesObject


44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 44

def class_nodes
  @class_nodes ||=
    if class_constant
      [
        s(:const, nil, class_constant),
        s(:const, s(:cbase), class_constant)
      ]
    else
      [nil]
    end
end

#correctable?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 56

def correctable?
  @correctable
end

#to_sObject


60
61
62
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 60

def to_s
  [class_constant, method].compact.join(delimeter)
end