Class: YearWeek
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #begin ⇒ Object
- #end ⇒ Object
- #gt(att) ⇒ Object
- #gteq(att) ⇒ Object
- #include?(other) ⇒ Boolean
- #lt(att) ⇒ Object
- #lteq(att) ⇒ Object
- #pred ⇒ Object
- #succ ⇒ Object
- #to_range ⇒ Object
- #to_s ⇒ Object
Class Method Details
.current ⇒ Object
23 24 25 |
# File 'lib/year_week.rb', line 23 def self.current for_date(Date.current) end |
.for_date(date) ⇒ Object
19 20 21 |
# File 'lib/year_week.rb', line 19 def self.for_date(date) new(date.cwyear, date.cweek) end |
Instance Method Details
#<=>(other) ⇒ Object
7 8 9 |
# File 'lib/year_week.rb', line 7 def <=>(other) to_s <=> other.to_s end |
#begin ⇒ Object
31 32 33 |
# File 'lib/year_week.rb', line 31 def begin DateTime.commercial(@year, @week) end |
#end ⇒ Object
35 36 37 |
# File 'lib/year_week.rb', line 35 def end DateTime.commercial(@year, @week, 7, 23, 59, 59) end |
#gt(att) ⇒ Object
55 56 57 |
# File 'lib/year_week.rb', line 55 def gt(att) att.lt(self.begin) end |
#gteq(att) ⇒ Object
59 60 61 |
# File 'lib/year_week.rb', line 59 def gteq(att) succ.gt(att) end |
#include?(other) ⇒ Boolean
15 16 17 |
# File 'lib/year_week.rb', line 15 def include?(other) to_range.include?(other.to_date) end |
#lt(att) ⇒ Object
47 48 49 |
# File 'lib/year_week.rb', line 47 def lt(att) att.gt(self.end) end |
#lteq(att) ⇒ Object
51 52 53 |
# File 'lib/year_week.rb', line 51 def lteq(att) pred.lt(att) end |
#pred ⇒ Object
43 44 45 |
# File 'lib/year_week.rb', line 43 def pred self.class.for_date(self.begin.prev_day) end |
#succ ⇒ Object
39 40 41 |
# File 'lib/year_week.rb', line 39 def succ self.class.for_date(self.begin.next_week) end |
#to_range ⇒ Object
27 28 29 |
# File 'lib/year_week.rb', line 27 def to_range (self.begin..self.end) end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/year_week.rb', line 11 def to_s "#{@year}-#{@week}" end |