Class: Erbcop::RubyExtractor
- Inherits:
-
Object
- Object
- Erbcop::RubyExtractor
- Defined in:
- lib/erbcop/ruby_extractor.rb
Overview
Extract Ruby codes from Erb 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.
26 27 28 29 |
# File 'lib/erbcop/ruby_extractor.rb', line 26 def initialize(file_path:, source:) @file_path = file_path @source = source end |
Class Method Details
.call(file_path:, source:) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/erbcop/ruby_extractor.rb', line 13 def call( file_path:, source: ) new( file_path: file_path, source: source ).call end |
Instance Method Details
#call ⇒ Array<Hash>
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/erbcop/ruby_extractor.rb', line 32 def call nodes.map do |node| snippet = node.children.first clipped = ::Templatecop::RubyClipper.new(snippet).call { code: clipped[:code], offset: node.location.begin_pos + clipped[:offset] } end end |