Class: RuboCop::Haml::RubyClipper
- Inherits:
-
Object
- Object
- RuboCop::Haml::RubyClipper
- Defined in:
- lib/rubocop/haml/ruby_clipper.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::Haml::RubyClip
-
#initialize(code) ⇒ RubyClipper
constructor
A new instance of RubyClipper.
Constructor Details
#initialize(code) ⇒ RubyClipper
Returns a new instance of RubyClipper.
16 17 18 |
# File 'lib/rubocop/haml/ruby_clipper.rb', line 16 def initialize(code) @code = code end |
Class Method Details
.call(code) ⇒ Hash
10 11 12 |
# File 'lib/rubocop/haml/ruby_clipper.rb', line 10 def call(code) new(code).call end |
Instance Method Details
#call ⇒ RuboCop::Haml::RubyClip
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/haml/ruby_clipper.rb', line 21 def call [ PrecedingKeywordRemover, TrailingDoRemover ].reduce( RubyClip.new( code: @code, offset: 0 ) ) do |previous, callable| result = callable.call(previous.code) RubyClip.new( code: result.code, offset: previous.offset + result.offset ) end end |