Class: Nrename::Directory
- Inherits:
-
Object
- Object
- Nrename::Directory
- Extended by:
- Forwardable
- Defined in:
- lib/nrename/directory.rb
Instance Attribute Summary collapse
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
Instance Method Summary collapse
- #directories ⇒ Object
- #files ⇒ Object
-
#initialize(dir) ⇒ Directory
constructor
A new instance of Directory.
- #max_number ⇒ Object
- #normalize ⇒ Object
- #num_field_length ⇒ Object
- #numbered_files ⇒ Object
- #regular_files ⇒ Object
Constructor Details
Instance Attribute Details
#counter ⇒ Object (readonly)
Returns the value of attribute counter.
12 13 14 |
# File 'lib/nrename/directory.rb', line 12 def counter @counter end |
Instance Method Details
#directories ⇒ Object
19 20 21 |
# File 'lib/nrename/directory.rb', line 19 def directories @dir.children.select &:directory? end |
#files ⇒ Object
27 28 29 |
# File 'lib/nrename/directory.rb', line 27 def files .rename_dirs ? directories : regular_files end |
#max_number ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/nrename/directory.rb', line 42 def max_number if .renumber numbered_files.size else numbered_files.map(&:number_from_path).max end end |
#normalize ⇒ Object
50 51 52 53 54 |
# File 'lib/nrename/directory.rb', line 50 def normalize numbered_files.each do |file| file.normalize end end |
#num_field_length ⇒ Object
38 39 40 |
# File 'lib/nrename/directory.rb', line 38 def num_field_length @num_field_length ||= max_number.to_s.size end |
#numbered_files ⇒ Object
31 32 33 34 35 36 |
# File 'lib/nrename/directory.rb', line 31 def numbered_files @numbered_files ||= files. select { |file| file.basename.to_s =~ .pattern }. map { |file| NumberedFile.new file, self }. sort_by(&:number_from_path) end |
#regular_files ⇒ Object
23 24 25 |
# File 'lib/nrename/directory.rb', line 23 def regular_files @dir.children.select &:file? end |