Class: FileRenamer::OptionParser

Inherits:
OptionParser
  • Object
show all
Defined in:
lib/filerenamer/optionparser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptionParser

Returns a new instance of OptionParser.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/filerenamer/optionparser.rb', line 19

def initialize
  @options = {}
  super
  on("-y", "--yes"     , "Yes for all questions."){@options[:yes]     = true}
  on("-n", "--no"      , "No  for all questions."){@options[:no]      = true}
  on("-c", "--copy"    , "Copy mode."            ){@options[:copy]    = true}
  on("-m", "--move"    , "Move mode.(default)"   ){@options[:move]    = true}
  on("-h", "--hardlink", "Hardlink mode."        ){@options[:hardlink]= true}
  on("-s", "--symlink" , "Symlink mode."         ){@options[:symlink] = true}
  on("-g", "--git"     , "Git-mv mode."          ){@options[:git]     = true}
  on("-q", "--quiet"   , "Quiet mode. Forced non-interactive."){
    @options[:quiet] = true
    @options[:yes]     = true
    #このオプションが設定されているときは強制的に --yes として扱われる。
    #non_interactive_mode になる。
  }
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/filerenamer/optionparser.rb', line 17

def options
  @options
end