Class: Pelusa::Lint::InstanceVariables

Inherits:
Object
  • Object
show all
Defined in:
lib/pelusa/lint/instance_variables.rb

Instance Method Summary collapse

Constructor Details

#initializeInstanceVariables

Returns a new instance of InstanceVariables


4
5
6
# File 'lib/pelusa/lint/instance_variables.rb', line 4

def initialize
  @ivars = Set.new
end

Instance Method Details

#check(klass) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/pelusa/lint/instance_variables.rb', line 8

def check(klass)
  iterate_lines!(klass)

  return SuccessfulAnalysis.new(name) if @ivars.length < limit

  FailedAnalysis.new(name, @ivars) do |ivars|
    "This class uses #{ivars.length} instance variables: #{ivars.to_a.join(', ')}."
  end
end