Class: Slimcop::RubyExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/slimcop/ruby_extractor.rb

Overview

Extract codes from Slim source.

Instance Method Summary collapse

Constructor Details

#initialize(file_path:, source:) ⇒ RubyExtractor

Returns a new instance of RubyExtractor.

Parameters:

  • file_path (String, nil)
  • source (String)


10
11
12
13
# File 'lib/slimcop/ruby_extractor.rb', line 10

def initialize(file_path:, source:)
  @file_path = file_path
  @source = source
end

Instance Method Details

#callArray<Hash>

Returns:

  • (Array<Hash>)


16
17
18
19
20
21
22
23
24
# File 'lib/slimcop/ruby_extractor.rb', line 16

def call
  ranges.map do |(begin_, end_)|
    {
      begin_: begin_,
      code: @source[begin_...end_],
      end_: end_
    }
  end
end