Class: CITLunch::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/pebbles/citlunch/client.rb

Constant Summary collapse

API_ENDPOINT =
"https://udon.upsilo.net/citlunch/api"

Instance Method Summary collapse

Instance Method Details

#get(place, date) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/pebbles/citlunch/client.rb', line 15

def get(place, date)
  url = "#{API_ENDPOINT}/#{place}/#{date.strftime("%Y-%m-%d")}/menu.json"
  begin
    open(url) {|f| JSON.parse(f.read).map {|r| Menu.new(r)}}
  rescue OpenURI::HTTPError
    nil
  end
end

#get_today(place) ⇒ Object



11
12
13
# File 'lib/pebbles/citlunch/client.rb', line 11

def get_today(place)
  get(place, Date.today)
end