Class: AtRandom::App
- Inherits:
-
Object
- Object
- AtRandom::App
- Defined in:
- lib/at-random/app.rb
Instance Method Summary collapse
-
#initialize(argv = []) ⇒ App
constructor
A new instance of App.
- #run ⇒ Object
Constructor Details
#initialize(argv = []) ⇒ App
Returns a new instance of App.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/at-random/app.rb', line 6 def initialize(argv=[]) @pick_time_opts = {} while argv[0] =~ /--(from|to|random-seed)/ arg = argv.shift if arg =~ /--from/ from_str = arg.length > 6 ? arg[7..-1] : argv.shift @pick_time_opts[:from] = from_str elsif arg =~ /--to/ to_str = arg.length > 4 ? arg[5..-1] : argv.shift @pick_time_opts[:to] = to_str elsif arg =~ /--random-seed/ @random_seed = (arg.length > 13 ? arg[14..-1] : argv.shift).to_i end end if @pick_time_opts[:from] && @pick_time_opts[:from].length == 2 @pick_time_opts[:from] += ':00' end if @pick_time_opts[:to] && @pick_time_opts[:to].length == 2 @pick_time_opts[:to] += ':59' end @at_args = argv end |