Method: Week#-
- Defined in:
- lib/sixarm_ruby_week/week.rb
#-(other) ⇒ Object
Subtraction: week - other => week or integer
If the other is a numeric value, return a week object pointing other weeks before self.
If the other is a week object, then return the difference between the two weeks.
Example:
week = Week.new(date)
week - 3 => three weeks earlier
Example:
a = Week.new(date)
b = Week.new(date + 21)
b - a => 3
Return:
* [Week]
263 264 265 266 267 268 269 270 271 |
# File 'lib/sixarm_ruby_week/week.rb', line 263 def -(other) if other.is_a? Numeric return Week.new(date - (other * 7)) elsif other.is_a? Week return ((self.date - other.date) / 7).round else raise TypeError end end |