Class: Slimcop::RubyExtractor
- Inherits:
-
Object
- Object
- Slimcop::RubyExtractor
- Defined in:
- lib/slimcop/ruby_extractor.rb
Overview
Extract Ruby codes from Slim source.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Array<Hash>
-
#initialize(file_path:, source:) ⇒ RubyExtractor
constructor
A new instance of RubyExtractor.
Constructor Details
#initialize(file_path:, source:) ⇒ RubyExtractor
Returns a new instance of RubyExtractor.
25 26 27 28 |
# File 'lib/slimcop/ruby_extractor.rb', line 25 def initialize(file_path:, source:) @file_path = file_path @source = source end |
Class Method Details
.call(file_path:, source:) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/slimcop/ruby_extractor.rb', line 12 def call( file_path:, source: ) new( file_path: file_path, source: source ).call end |
Instance Method Details
#call ⇒ Array<Hash>
31 32 33 34 35 36 37 38 39 |
# File 'lib/slimcop/ruby_extractor.rb', line 31 def call ranges.map do |(begin_, end_)| clipped = ::Templatecop::RubyClipper.new(@source[begin_...end_]).call { code: clipped[:code], offset: begin_ + clipped[:offset] } end end |