Skip to content

Instantly share code, notes, and snippets.

@romulostorel
Created December 5, 2012 17:08
Show Gist options
  • Save romulostorel/4217525 to your computer and use it in GitHub Desktop.
Save romulostorel/4217525 to your computer and use it in GitHub Desktop.
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