Class: FileScanner::Worker
- Inherits:
-
Object
- Object
- FileScanner::Worker
- Defined in:
- lib/file_scanner/worker.rb
Constant Summary collapse
- SLICE =
1000- ALL =
:all?- ANY =
:any?
Instance Attribute Summary collapse
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path:, filters: Filters::defaults, slice: SLICE, all: false, check: false, logger: Logger.new(nil)) ⇒ Worker
constructor
A new instance of Worker.
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.(path) @filters = filters @slice = slice.to_i @mode = mode(all) @check = check @logger = logger end |
Instance Attribute Details
#filters ⇒ Object (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
#call ⇒ Object
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. } raise e end |