Class: RestaurantWeekBoston::Runner
- Inherits:
-
Object
- Object
- RestaurantWeekBoston::Runner
- Defined in:
- lib/restaurant_week_boston/runner.rb
Overview
Used in the executable script, restaurant_week_boston
.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
Pass in ARGV.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Runner
Pass in ARGV.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/restaurant_week_boston/runner.rb', line 9 def initialize(argv) = {} optparse = OptionParser.new do |opts| opts. = "Usage: #{$0} [options] restaurant1, restaurant2, ..." [:meal] = :any opts.on('-m', '--meal MEAL', 'Only get restaurants that offer this meal (lunch/dinner/both/any)') do |m| [:meal] = m end opts.on('-l', '--lunch RESTO1,RESTO2', 'Mark RESTAURANTS as good for lunch') do |lunches| [:lunch] = lunches.split(',') end opts.on('-d', '--dinner RESTO1,RESTO2', 'Mark RESTAURANTS as good for dinner') do |dinners| [:dinner] = dinners.split(',') end opts.on('-a', '--any RESTO1,RESTO2', 'Mark RESTAURANTS as good for any meal') do |any| [:any] = any.split(',') end [:neighborhood] = :all # NOT any! opts.on('-n', '--neighborhood HOOD', 'Only get restaurants in this neighborhood (dorchester, back-bay, etc)') do |n| n = :all if n == 'any' # :any makes it choke [:neighborhood] = n end opts.on('-h', '--help', 'Display this help') do puts opts return end end optparse.parse!(argv) @options = end |