Class: RuboCop::Slim::KeywordRemover
- Inherits:
-
Object
- Object
- RuboCop::Slim::KeywordRemover
- Defined in:
- lib/rubocop/slim/keyword_remover.rb
Overview
Remove unnecessary part (e.g. ‘if`, `unless`, `do`, …) from Ruby-ish code.
Defined Under Namespace
Classes: PrecedingKeywordRemover, TrailingDoRemover
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ RuboCop::Slim::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/slim/keyword_remover.rb', line 16 def initialize(ruby_clip) @ruby_clip = ruby_clip end |
Class Method Details
.call(ruby_clip) ⇒ RuboCop::Slim::RubyClip
10 11 12 |
# File 'lib/rubocop/slim/keyword_remover.rb', line 10 def call(ruby_clip) new(ruby_clip).call end |
Instance Method Details
#call ⇒ RuboCop::Slim::RubyClip
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubocop/slim/keyword_remover.rb', line 21 def call [ PrecedingKeywordRemover, TrailingDoRemover ].reduce(@ruby_clip) do |previous, callable| result = callable.call(previous.code) RubyClip.new( code: result.code, offset: previous.offset + result.offset ) end end |