Class: RuboCop::Haml::RubyExtractor
- Inherits:
-
Object
- Object
- RuboCop::Haml::RubyExtractor
- Defined in:
- lib/rubocop/haml/ruby_extractor.rb
Overview
Extract Ruby codes from Haml template.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Array<RuboCop::ProcessedSource>?
-
#initialize(processed_source) ⇒ RubyExtractor
constructor
A new instance of RubyExtractor.
Constructor Details
#initialize(processed_source) ⇒ RubyExtractor
Returns a new instance of RubyExtractor.
19 20 21 |
# File 'lib/rubocop/haml/ruby_extractor.rb', line 19 def initialize(processed_source) @processed_source = processed_source end |
Class Method Details
.call(processed_source) ⇒ Array<RuboCop::ProcessedSource>?
13 14 15 |
# File 'lib/rubocop/haml/ruby_extractor.rb', line 13 def call(processed_source) new(processed_source).call end |
Instance Method Details
#call ⇒ Array<RuboCop::ProcessedSource>?
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rubocop/haml/ruby_extractor.rb', line 24 def call return unless supported_file_path_pattern? ruby_ranges.map do |(begin_, end_)| clip = RubyClipper.new(template_source[begin_...end_]).call processed_source = ::RuboCop::ProcessedSource.new( clip[:code], @processed_source.ruby_version, file_path ) processed_source.config = @processed_source.config processed_source.registry = @processed_source.registry { offset: begin_ + clip[:offset], processed_source: processed_source } end end |