Sha256: a210e3e9b19f5a983b63d0a479ac6b140d1971896750c846032732b528c48aab
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
module Calendrier module EventHelper def count_sorted_events(events_by_date, cell_begin_time, cell_end_time) counter = 0 sorted_events_do(events_by_date, cell_begin_time, cell_end_time) { |event| counter += 1 } counter end def yield_sorted_events(events_by_date, cell_begin_time, cell_end_time, &block) sorted_events_do(events_by_date, cell_begin_time, cell_end_time) { |event| yield event } end protected def sorted_events_do(events_by_date, cell_begin_time, cell_end_time, &block) begin unless events_by_date[cell_begin_time.year.to_s][cell_begin_time.month.to_s][cell_begin_time.day.to_s].nil? events_by_date[cell_begin_time.year.to_s][cell_begin_time.month.to_s][cell_begin_time.day.to_s].each do |event| yield event if display_event?(event, cell_begin_time, cell_end_time) # && block_given? end end rescue NoMethodError end end def display_event?(event, cell_begin_time, cell_end_time) event_begin_time = nil event_end_time = nil if event.respond_to?(:year) && event.respond_to?(:month) && event.respond_to?(:day) event_begin_time = Time.utc(event.year, event.month, event.day) event_end_time = Time.utc(event.year, event.month, event.day, 23, 59, 59) end if event.respond_to?(:begin_time) && event.respond_to?(:end_time) event_begin_time = event.begin_time event_end_time = event.end_time end if event_begin_time.to_i <= cell_begin_time.to_i if event_end_time.to_i <= cell_end_time.to_i if event_end_time.to_i > cell_begin_time.to_i ok = true end else ok = true end else if event_end_time.to_i <= cell_end_time.to_i ok = true else if event_begin_time.to_i < cell_end_time.to_i ok = true end end end return ok end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
calendrier-0.9.0 | lib/calendrier/helpers/event_helper.rb |