Created
June 25, 2017 18:56
-
-
Save mariorcardoso/513bc0a7db1aef05336da4ff1446747b 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
class DateRange < Value.new(:start_date, :end_date) | |
def include_date?(date) | |
date >= start_date && date <= end_date | |
end | |
def include_date_range?(date_range) | |
start_date <= date_range.start_date && end_date >= date_range.end_date | |
end | |
def overlap_date_range?(date_range) | |
start_date <= date_range.end_date && end_date >= date_range.start_date | |
end | |
def to_s | |
"from #{start_date.strftime('%d-%B-%Y')} to #{end_date.strftime('%d-%B-%Y')}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment