Class: Fixnames::Engine::ScanDir

Inherits:
Object
  • Object
show all
Defined in:
lib/fixnames/engine/scan_dir.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (ScanDir) initialize(dirname, opts)

A new instance of ScanDir



5
6
7
8
9
10
11
# File 'lib/fixnames/engine/scan_dir.rb', line 5

def initialize(dirname, opts)
  raise "Not a directory: #{dirname}" unless File.directory?(dirname)
  @name = File.realpath(dirname)
  raise "Not a directory: #{name}" unless File.directory?(name)

  @option = opts
end

Instance Attribute Details

- (Object) base (readonly)

Returns the value of attribute base



4
5
6
# File 'lib/fixnames/engine/scan_dir.rb', line 4

def base
  @base
end

- (Object) name (readonly)

Returns the value of attribute name



4
5
6
# File 'lib/fixnames/engine/scan_dir.rb', line 4

def name
  @name
end

- (Object) option (readonly)

Returns the value of attribute option



4
5
6
# File 'lib/fixnames/engine/scan_dir.rb', line 4

def option
  @option
end

- (Object) prefix (readonly)

Returns the value of attribute prefix



4
5
6
# File 'lib/fixnames/engine/scan_dir.rb', line 4

def prefix
  @prefix
end

Instance Method Details

- (Object) engines



21
22
23
24
25
# File 'lib/fixnames/engine/scan_dir.rb', line 21

def engines
  @engies ||= files.map do |name|
    Engine.new(name, option)
  end
end

- (Object) files



17
18
19
# File 'lib/fixnames/engine/scan_dir.rb', line 17

def files
  @files ||= Dir.glob(glob_str)
end

- (Object) fix!



27
28
29
30
31
# File 'lib/fixnames/engine/scan_dir.rb', line 27

def fix!
  engines.map do |en|
    en.fix!
  end
end

- (Object) glob_str



13
14
15
# File 'lib/fixnames/engine/scan_dir.rb', line 13

def glob_str
  "#{name}/#{option.dir_glob}"
end