diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/chaos_calendar.rb | 35 | ||||
| -rwxr-xr-x[-rw-r--r--] | lib/chaos_calendar/gen.sh | 0 |
2 files changed, 0 insertions, 35 deletions
diff --git a/lib/chaos_calendar.rb b/lib/chaos_calendar.rb deleted file mode 100644 index b363ccb..0000000 --- a/lib/chaos_calendar.rb +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | require 'vpim' | ||
| 2 | |||
| 3 | class Occurrence | ||
| 4 | def initialize start, event, node | ||
| 5 | @dtstart = start | ||
| 6 | @event = event | ||
| 7 | @node = node | ||
| 8 | end | ||
| 9 | attr_reader :dtstart, :event, :node | ||
| 10 | end | ||
| 11 | |||
| 12 | class ChaosCalendar | ||
| 13 | attr_reader :calendar | ||
| 14 | def initialize | ||
| 15 | @calendar = {} | ||
| 16 | end | ||
| 17 | |||
| 18 | def push cal, node | ||
| 19 | Vpim::Icalendar.decode( cal ).each { |c| c.events.each { |e| @calendar[e] = node } } | ||
| 20 | end | ||
| 21 | |||
| 22 | def occurrences start_time, end_time | ||
| 23 | occurr = [] | ||
| 24 | @calendar.each { |e, node| | ||
| 25 | if e.occurs_in?( start_time, end_time ) | ||
| 26 | e.occurences( end_time ) { |t| | ||
| 27 | occurr << Occurrence.new(t,e,node) if (t + (e.duration || 0)) >= start_time | ||
| 28 | } | ||
| 29 | end | ||
| 30 | } | ||
| 31 | |||
| 32 | return occurr.sort { |lhs, rhs| lhs.dtstart <=> rhs.dtstart } | ||
| 33 | end | ||
| 34 | |||
| 35 | end | ||
diff --git a/lib/chaos_calendar/gen.sh b/lib/chaos_calendar/gen.sh index 2f5351a..2f5351a 100644..100755 --- a/lib/chaos_calendar/gen.sh +++ b/lib/chaos_calendar/gen.sh | |||
