Skip to content

Instantly share code, notes, and snippets.

@moonhouse
Created September 8, 2015 07:31
Show Gist options
  • Select an option

  • Save moonhouse/d01b335093af2440114c to your computer and use it in GitHub Desktop.

Select an option

Save moonhouse/d01b335093af2440114c to your computer and use it in GitHub Desktop.
Ta fram dagens meny från Pontus utifrån deras meny-PDF
require 'pdf-reader'
weekdays = %w{Söndag Måndag Tisdag Onsdag Torsdag Fredag Lördag}
reader = PDF::Reader.new("P4_V.37.-15.pdf")
page = reader.pages.first
week_menu = {}
week_menu.default = ''
current_weekday = ''
page.text.each_line do |line|
if weekdays.include? line.strip
current_weekday = line.strip
elsif line.strip.length > 0
week_menu[current_weekday] += line
end
end
today = weekdays[Time.now.wday]
puts "*Meny #{today.downcase}* (Pontus)"
puts week_menu[today]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment