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

#initialize(dirname, opts) ⇒ ScanDir

Returns 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

#baseObject (readonly)

Returns the value of attribute base.



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

def base
  @base
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#optionObject (readonly)

Returns the value of attribute option.



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

def option
  @option
end

#prefixObject (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

#enginesObject



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

#filesObject



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

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

#fix!Object



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

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

#glob_strObject



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

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