Class: RestaurantWeekBoston::Marker

Inherits:
Object
  • Object
show all
Defined in:
lib/restaurant_week_boston/marker.rb

Overview

Uses a given Scraper and marks restaurants as good for lunch, dinner, any, etc.

Instance Method Summary collapse

Constructor Details

#initialize(scraper, opts) ⇒ Marker

opts is a hash with keys for :lunch, :dinner, and :any. The values of each of these keys should be an array suitable for passing to Scraper#special_find().



10
11
12
13
# File 'lib/restaurant_week_boston/marker.rb', line 10

def initialize(scraper, opts)
  @scraper = scraper
  @opts = opts
end

Instance Method Details

#allObject

Print lunch(), dinner(), and any(), with newlines between them.



55
56
57
58
59
60
61
# File 'lib/restaurant_week_boston/marker.rb', line 55

def all
  lunch()
  puts
  dinner()
  puts
  any()
end

#anyObject

Print out restaurants that are good for lunch or dinner.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/restaurant_week_boston/marker.rb', line 42

def any
  unless @any
    if @opts.key?(:any)
      @any = @scraper.special_find(@opts[:any])
    else
      @any = '[no "lunch or dinner" options specified]'
    end
  end
  puts "=== LUNCH OR DINNER ==="
  puts @any
end

#dinnerObject

Print out restaurants that are good for dinner.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/restaurant_week_boston/marker.rb', line 29

def dinner
  unless @dinner
    if @opts.key?(:dinner)
      @dinner = @scraper.special_find(@opts[:dinner])
    else
      @dinner = '[no dinner options specified]'
    end
  end
  puts "=== DINNER ==="
  puts @dinner
end

#lunchObject

Print out restaurants that are good for lunch.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/restaurant_week_boston/marker.rb', line 16

def lunch
  unless @lunch
    if @opts.key?(:lunch)
      @lunch = @scraper.special_find(@opts[:lunch])
    else
      @lunch = '[no lunch options specified]'
    end
  end
  puts "=== LUNCH ==="
  puts @lunch
end