Class: RuboCop::Erb::KeywordRemover::PrecedingSourceRemover

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/erb/keyword_remover.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ PrecedingSourceRemover

Returns a new instance of PrecedingSourceRemover.

Parameters:

  • code (String)


47
48
49
# File 'lib/rubocop/erb/keyword_remover.rb', line 47

def initialize(code)
  @code = code
end

Class Method Details

.call(code) ⇒ RubyClip

Parameters:

  • code (String)

Returns:



41
42
43
# File 'lib/rubocop/erb/keyword_remover.rb', line 41

def call(code)
  new(code).call
end

Instance Method Details

#callHash

Returns:

  • (Hash)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rubocop/erb/keyword_remover.rb', line 52

def call
  data = @code.match(self.class::REGEXP)
  if data
    offset = data[0].length
    RubyClip.new(
      code: @code[offset..],
      offset: offset
    )
  else
    RubyClip.new(
      code: @code,
      offset: 0
    )
  end
end