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.


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

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.


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

def class_constant
  @class_constant
end

#methodObject (readonly)

Returns the value of attribute method.


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

def method
  @method
end

Instance Method Details

#class_nodesObject


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

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)

58
59
60
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 58

def correctable?
  @correctable
end

#to_sObject


62
63
64
# File 'lib/rubocop/cop/lint/deprecated_class_methods.rb', line 62

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