Class: RuboCop::Erb::KeywordRemover
- Inherits:
-
Object
- Object
- RuboCop::Erb::KeywordRemover
- Defined in:
- lib/rubocop/erb/keyword_remover.rb
Overview
Remove unnecessary keyword part (e.g. ‘if`, `unless`, `do`, …) from Ruby-ish code.
Defined Under Namespace
Classes: PrecedingBraceRemover, PrecedingKeywordRemover, PrecedingSourceRemover, TrailingBraceRemover, TrailingDoRemover, TrailingSourceRemover, TrailingThenRemover
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ RuboCop::Erb::RubyClip
-
#initialize(ruby_clip) ⇒ KeywordRemover
constructor
A new instance of KeywordRemover.
Constructor Details
#initialize(ruby_clip) ⇒ KeywordRemover
Returns a new instance of KeywordRemover.
16 17 18 |
# File 'lib/rubocop/erb/keyword_remover.rb', line 16 def initialize(ruby_clip) @ruby_clip = ruby_clip end |
Class Method Details
.call(ruby_clip) ⇒ RuboCop::Erb::RubyClip
10 11 12 |
# File 'lib/rubocop/erb/keyword_remover.rb', line 10 def call(ruby_clip) new(ruby_clip).call end |
Instance Method Details
#call ⇒ RuboCop::Erb::RubyClip
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubocop/erb/keyword_remover.rb', line 21 def call [ PrecedingKeywordRemover, PrecedingBraceRemover, TrailingBraceRemover, TrailingThenRemover, TrailingDoRemover ].reduce(@ruby_clip) do |previous, callable| result = callable.call(previous.code) RubyClip.new( code: result.code, offset: previous.offset + result.offset ) end end |