Class: Modname::Driver
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize ⇒ Driver
constructor
A new instance of Driver.
-
#parse(args) ⇒ Object
parse out arguments.
-
#run(args) ⇒ Object
parse user arguments.
Methods included from Modder
confirm?, execute, #exts, files, finish, parse, #regex, rename, status, #undercase_ext, undercase_ext_get, undercase_ext_set
Constructor Details
#initialize ⇒ Driver
Returns a new instance of Driver.
22 23 24 25 |
# File 'lib/modname.rb', line 22 def initialize @options = {:force => false, :recurse => false} @transfer = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
20 21 22 |
# File 'lib/modname.rb', line 20 def @options end |
Instance Method Details
#parse(args) ⇒ Object
parse out arguments
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/modname.rb', line 52 def parse(args) opts = {:cmd => "file", :args => []} args.each do |opt| case opt when "-f" @options[:force] = true when "-r" @options[:recurse] = true when "-e", "--ext" opts[:cmd] = "ext" when "-h", "--help" opts[:cmd] = "help" when "-v", "--version" opts[:cmd] = "version" else # command argument opts[:args] << opt end end opts end |
#run(args) ⇒ Object
parse user arguments
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/modname.rb', line 28 def run(args) if args.empty? puts Modname::HelpBanner else opts = parse args cmd = opts[:cmd] case cmd when "file" regex opts[:args] when "ext" exts opts[:args] when "help" puts Modname::VHelpBanner when "version" puts Modname::Version end end end |