Class: Mvmv
- Inherits:
-
Object
- Object
- Mvmv
- Defined in:
- lib/mvmv.rb,
lib/mvmv/command.rb,
lib/mvmv/version.rb
Defined Under Namespace
Modules: Command
Constant Summary collapse
- VERSION =
"0.1.2"
Instance Method Summary collapse
- #convert_filenames(symb, *args) ⇒ Object
-
#initialize(color = true, outstream = $stdout, instream = $stdin) ⇒ Mvmv
constructor
A new instance of Mvmv.
- #rename(symb, *args) ⇒ Object
- #rename!(symb, *args) ⇒ Object
Constructor Details
#initialize(color = true, outstream = $stdout, instream = $stdin) ⇒ Mvmv
Returns a new instance of Mvmv.
6 7 8 9 10 |
# File 'lib/mvmv.rb', line 6 def initialize color = true, outstream = $stdout, instream = $stdin @color = color @outstream = outstream @instream = instream end |
Instance Method Details
#convert_filenames(symb, *args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mvmv.rb', line 12 def convert_filenames symb, *args unless Mvmv::Command.respond_to?(symb) error "Invalid command: #{symb}" end arg_arity = Mvmv::Command.method(symb).arity - 1 if arg_arity >= args.length error "Invalid number of parameters for #{symb.to_s.gsub('_', '-')}", ArgumentError end files = args[arg_arity..-1] dir_files = files.map { |f| [f.include?('/') ? File.dirname(f) : nil, File.basename(f)] } files.zip( dir_files.map(&:first).zip( Mvmv::Command.send(symb, *(args[0, arg_arity] + [dir_files.map(&:last)])) ).map { |pair| pair.compact.join('/') } ) end |
#rename(symb, *args) ⇒ Object
31 32 33 |
# File 'lib/mvmv.rb', line 31 def rename symb, *args rename_impl false, symb, *args end |
#rename!(symb, *args) ⇒ Object
35 36 37 |
# File 'lib/mvmv.rb', line 35 def rename! symb, *args rename_impl true, symb, *args end |