Class: ImgSort
- Inherits:
-
Object
- Object
- ImgSort
- Defined in:
- lib/img-sort.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(arguments = {}) ⇒ ImgSort
constructor
A new instance of ImgSort.
-
#run ⇒ Object
Parse options, check arguments, then process the command.
Constructor Details
#initialize(arguments = {}) ⇒ ImgSort
Returns a new instance of ImgSort.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/img-sort.rb', line 14 def initialize(arguments = {}) @arguments = arguments # Set defaults @options = OpenStruct.new @options.verbose = false @options.quiet = false @options.rename = true @options.hash_function = 'md5' @options.unsort = false @options.copy = false # Init options parser @opt_parser = self.opts_parser end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/img-sort.rb', line 10 def @options end |
Instance Method Details
#run ⇒ Object
Parse options, check arguments, then process the command
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/img-sort.rb', line 30 def run if ( && arguments_valid?) @start_date = Time.now puts "Start at #{@start_date}\n" if @options.verbose if @options.verbose case set_path!(@arguments[0], @arguments[1]) when 1 puts "Source directory doesn't exists!" exit 1 when 2 puts "Source directory is empty!" exit 2 end unsort? ? unsort! : sort! @end_date = Time.now puts "Finished at #{@end_date}\n" if @options.verbose puts "Time wasted: #{Time.at(@end_date - @start_date).gmtime.strftime('%R:%S')}" unless @options.quite else output_usage end end |