Class: RuboCop::Kata::Variable::Gap

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/kata/variable/gap.rb

Overview

SPDX-FileCopyrightText: Copyright (c) 2019-2026 Yegor Bugayenko SPDX-License-Identifier: MIT Derived from rubocop-elegant (https://github.com/yegor256/rubocop-elegant), see LICENSE.txt

Constant Summary collapse

PURE =
%i[
  int float rational complex str sym true false nil array hash regexp regopt
  irange erange lvar self pair begin
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(movable) ⇒ Gap

Returns a new instance of Gap.



13
14
15
16
# File 'lib/rubocop/kata/variable/gap.rb', line 13

def initialize(movable)
  @movable = movable
  @memo = {}
end

Instance Method Details

#crossed?(assign, read) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/rubocop/kata/variable/gap.rb', line 18

def crossed?(assign, read)
  @memo[assign] = scan?(assign, read) unless @memo.key?(assign)
  @memo[assign]
end