Class: Fixnames::Engine::ScanDir
- Inherits:
-
Object
- Object
- Fixnames::Engine::ScanDir
- Defined in:
- lib/fixnames/engine/scan_dir.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#option ⇒ Object
readonly
Returns the value of attribute option.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
- #engines ⇒ Object
- #files ⇒ Object
- #fix! ⇒ Object
- #glob_str ⇒ Object
-
#initialize(dirname, opts) ⇒ ScanDir
constructor
A new instance of ScanDir.
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
#base ⇒ Object (readonly)
Returns the value of attribute base.
4 5 6 |
# File 'lib/fixnames/engine/scan_dir.rb', line 4 def base @base end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/fixnames/engine/scan_dir.rb', line 4 def name @name end |
#option ⇒ Object (readonly)
Returns the value of attribute option.
4 5 6 |
# File 'lib/fixnames/engine/scan_dir.rb', line 4 def option @option end |
#prefix ⇒ Object (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
#engines ⇒ Object
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 |
#files ⇒ Object
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_str ⇒ Object
13 14 15 |
# File 'lib/fixnames/engine/scan_dir.rb', line 13 def glob_str "#{name}/#{option.dir_glob}" end |