Created
December 5, 2012 17:08
-
-
Save romulostorel/4217525 to your computer and use it in GitHub Desktop.
This file contains 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
def has_conflict_of_times_in_activities?(schedule_activities) | |
items = [] | |
schedule_activities.each do |schedule_activity| | |
if has_time_intersection?(schedule_activity) | |
items << schedule_activity | |
end | |
end | |
items.any? | |
end | |
protected | |
def has_time_intersection?(schedule_activity) | |
(schedule_activity.time_range.include? start_time.to_s(:time)) || (schedule_activity.time_range.include? end_time.to_s(:time)) | |
end | |
def time_range | |
start_time.to_s(:time)..end_time.to_s(:time) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment