Skip to content

Instantly share code, notes, and snippets.

@jesjos
Created October 17, 2010 21:42
Show Gist options
  • Save jesjos/631326 to your computer and use it in GitHub Desktop.
Save jesjos/631326 to your computer and use it in GitHub Desktop.
model
class Calendar < ActiveRecord::Base
def self.get_rooms
c = Marshal.load(Calendar.last.cal_dump)
events = {}
c.events.each do |c|
if events.has_key? c.location
events[c.location].push(c.occurences.first)
else
events.store(c.location, Array[c.occurences.first])
end
end
return events
end
def self.get_rooms_today
rooms = self.get_rooms
rooms.each_key do |room|
rooms[room].delete_if {|time| time.today?}
end
return rooms
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment