Class: FileScanner::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/file_scanner/worker.rb

Constant Summary collapse

SLICE =
1000
ALL =
:all?
ANY =
:any?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, filters: Filters::defaults, slice: SLICE, all: false, check: false, logger: Logger.new(nil)) ⇒ Worker

Returns a new instance of Worker.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/file_scanner/worker.rb', line 13

def initialize(path:, 
               filters: Filters::defaults, 
               slice: SLICE, 
               all: false, 
               check: false,
               logger: Logger.new(nil))
  @path = File.expand_path(path)
  @filters = filters
  @slice = slice.to_i
  @mode = mode(all)
  @check = check
  @logger = logger
end

Instance Attribute Details

#filtersObject (readonly)

Returns the value of attribute filters.



11
12
13
# File 'lib/file_scanner/worker.rb', line 11

def filters
  @filters
end

Instance Method Details

#callObject



27
28
29
30
31
32
33
34
35
# File 'lib/file_scanner/worker.rb', line 27

def call
  return slices unless block_given?
  slices.each do |slice|
    yield(slice, @logger)
  end
rescue StandardError => e
  @logger.error { e.message }
  raise e
end