Created
October 17, 2010 21:42
-
-
Save jesjos/631326 to your computer and use it in GitHub Desktop.
model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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