Sha256: 521c72dcbd1b8a02f4152cc2787e4e3373ef1e3ed962f3e88b9c0c33f9928c2f
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# -*- encoding : utf-8 -*- require "rest-client" require "nokogiri" require "prowl" require "einstein/container" require "titleize" require "date" class Einstein include EinsteinContainer def self.method_missing(meth, *args, &blk) Einstein.new.send(meth, *args, &blk) end def menu_for(whenever) data = content.css("td.bg_lunchmeny p").to_a[1..-2].map do |p| list = p.content.split("\r\n") {list[0].gsub(/"|:|\s+/, "") => list[1..-1].map { |item| item.gsub(/• /, "").strip }} end.inject({}) { |a, b| a.merge(b) } whenever = days.keys[Date.today.wday] if whenever == :today data = data[days[whenever]] || [] Container.new(data, whenever) end private def content @_content ||= Nokogiri::HTML(download) end def download @_download ||= RestClient.get("http://www.butlercatering.se/einstein.html", timeout: 10) end def days @_days ||= { sunday: "Sön", monday: "Mån", tuesday: "Tis", wednesday: "Ons", thursday: "Tors", friday: "Fre", saturday: "Lör" } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
einstein-0.0.1 | lib/einstein.rb |