Class: Templatecop::RubyClipper
- Inherits:
-
Object
- Object
- Templatecop::RubyClipper
- Defined in:
- lib/templatecop/ruby_clipper.rb
Overview
Remove unnecessary part (e.g. ‘if`, `unless`, `do`, …) from Ruby code.
Defined Under Namespace
Classes: PrecedingKeywordRemover, TrailingDoRemover
Instance Method Summary collapse
- #call ⇒ Hash
-
#initialize(code) ⇒ RubyClipper
constructor
A new instance of RubyClipper.
Constructor Details
#initialize(code) ⇒ RubyClipper
Returns a new instance of RubyClipper.
7 8 9 |
# File 'lib/templatecop/ruby_clipper.rb', line 7 def initialize(code) @code = code end |
Instance Method Details
#call ⇒ Hash
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/templatecop/ruby_clipper.rb', line 12 def call [ PrecedingKeywordRemover, TrailingDoRemover ].each_with_object( code: @code, offset: 0 ) do |klass, object| result = klass.new(object[:code]).call object[:code] = result[:code] object[:offset] += result[:offset] end end |