Class: FileScanner::Client

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

Overview

Create a scanner client

Author:

  • c477y

Instance Method Summary collapse

Constructor Details

#initialize(dir, **options) ⇒ Client

Create a new Scanner

Parameters:

  • dir (String)

    Directory to be processed

  • options (Hash)

Options Hash (**options):

  • :nested (Boolean)

    Specify if nested directories should be scanned

  • extension (String)

    Extension of filenames to be selected. Defaults to “*.mp4”



15
16
17
18
19
20
# File 'lib/file_scanner/client.rb', line 15

def initialize(dir, **options)
  @nested = options[:nested]
  @extension = options[:extension].nil? ? "*.mp4" : options[:extension]
  @logger = options[:logger] || $stdout
  @dir = dir
end

Instance Method Details

#each(&block) ⇒ Object

Parameters:

  • block (Proc)

    Block of code to be executed for each file



23
24
25
26
# File 'lib/file_scanner/client.rb', line 23

def each(&block)
  @block = block
  process_directory(@dir)
end