Class: RuboCop::Slim::KeywordRemover::TrailingDoRemover

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

Overview

Remove trailing ‘do`.

Constant Summary collapse

REGEXP =
/
  (?:\b[ \t]*|[ \t])
  do
  [ \t]*
  (\|[^|]*\|)?
  [ \t]*
  (\#.*)?
  \Z
/x.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ TrailingDoRemover

Returns a new instance of TrailingDoRemover.

Parameters:

  • code (String)


107
108
109
# File 'lib/rubocop/slim/keyword_remover.rb', line 107

def initialize(code)
  @code = code
end

Class Method Details

.call(code) ⇒ RubyClip

Parameters:

  • code (String)

Returns:



101
102
103
# File 'lib/rubocop/slim/keyword_remover.rb', line 101

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

Instance Method Details

#callHash

Returns:

  • (Hash)


112
113
114
115
116
117
# File 'lib/rubocop/slim/keyword_remover.rb', line 112

def call
  RubyClip.new(
    code: @code.sub(REGEXP, ''),
    offset: 0
  )
end