Class: DailyMenuApp::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/daily_menu_app/fetcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Fetcher

Returns a new instance of Fetcher.



6
7
8
# File 'lib/daily_menu_app/fetcher.rb', line 6

def initialize(logger)
  @logger = logger
end

Instance Method Details

#fetch(location) ⇒ Object



10
11
12
13
14
15
# File 'lib/daily_menu_app/fetcher.rb', line 10

def fetch(location)
  menus = fetch_menus(location).map do |restaurant, entry|
    [restaurant.name, convert_entry(entry)]
  end
  Hash[menus]
end

#fetch_menus(location) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/daily_menu_app/fetcher.rb', line 17

def fetch_menus(location)
  DailyMenu.menus_for(location)
rescue RuntimeError => e
  expectation = expectation_class_from(e).new(e.message)
  expectation.set_backtrace(e.backtrace)
  raise expectation
end