Class: TimeBoss::Calendar::Period
- Inherits:
-
Object
- Object
- TimeBoss::Calendar::Period
- Defined in:
- lib/timeboss/calendar/period.rb
Instance Attribute Summary collapse
-
#begin ⇒ Object
readonly
Returns the value of attribute begin.
-
#end ⇒ Object
readonly
Returns the value of attribute end.
Instance Method Summary collapse
-
#current? ⇒ Boolean
Does this period cover the current date?.
-
#day(index = nil) ⇒ Array<Calendar::Day>?
Get the day this period represents.
-
#days ⇒ Array<Calendar::Day>
Get a list of days that fall within this period.
-
#end_date ⇒ Date
Get the end date of this period.
-
#half(index = nil) ⇒ Array<Calendar::Half>?
Get the half this period represents.
-
#halves ⇒ Array<Calendar::Half>
Get a list of halves that fall within this period.
- #inspect ⇒ Object
-
#month(index = nil) ⇒ Array<Calendar::Month>?
Get the month this period represents.
-
#months ⇒ Array<Calendar::Month>
Get a list of months that fall within this period.
-
#name ⇒ String
Get a simple representation of this period.
-
#quarter(index = nil) ⇒ Array<Calendar::Quarter>?
Get the quarter this period represents.
-
#quarters ⇒ Array<Calendar::Quarter>
Get a list of quarters that fall within this period.
-
#start_date ⇒ Date
Get the start date of this period.
-
#title ⇒ String
Get a “pretty” representation of this period.
-
#to_range ⇒ Range<Date, Date>
Express this period as a date range.
-
#to_s ⇒ String
Get a stringified representation of this period.
-
#week(index = nil) ⇒ Array<Calendar::Week>?
Get the week this period represents.
-
#weeks ⇒ Array<Calendar::Week>
Get a list of weeks that fall within this period.
-
#year(index = nil) ⇒ Array<Calendar::Year>?
Get the year this period represents.
-
#years ⇒ Array<Calendar::Year>
Get a list of years that fall within this period.
Instance Attribute Details
#begin ⇒ Object (readonly)
Returns the value of attribute begin.
6 7 8 |
# File 'lib/timeboss/calendar/period.rb', line 6 def begin @begin end |
#end ⇒ Object (readonly)
Returns the value of attribute end.
6 7 8 |
# File 'lib/timeboss/calendar/period.rb', line 6 def end @end end |
Instance Method Details
#current? ⇒ Boolean
Does this period cover the current date?
110 111 112 |
# File 'lib/timeboss/calendar/period.rb', line 110 def current? to_range.include?(Date.today) end |
#day(index = nil) ⇒ Array<Calendar::Day>?
Get the day this period represents. Returns nil if no single day can be identified.
|
# File 'lib/timeboss/calendar/period.rb', line 48
|
#days ⇒ Array<Calendar::Day>
Get a list of days that fall within this period.
|
# File 'lib/timeboss/calendar/period.rb', line 44
|
#end_date ⇒ Date
Get the end date of this period.
16 |
# File 'lib/timeboss/calendar/period.rb', line 16 delegate :end_date, to: :end |
#half(index = nil) ⇒ Array<Calendar::Half>?
Get the half this period represents. Returns nil if no single half can be identified.
|
# File 'lib/timeboss/calendar/period.rb', line 92
|
#halves ⇒ Array<Calendar::Half>
Get a list of halves that fall within this period.
|
# File 'lib/timeboss/calendar/period.rb', line 88
|
#inspect ⇒ Object
136 137 138 |
# File 'lib/timeboss/calendar/period.rb', line 136 def inspect "#<#{self.class.name}[#{self.begin.inspect}..#{self.end.inspect}] start_date=#{start_date}, end_date=#{end_date}>" end |
#month(index = nil) ⇒ Array<Calendar::Month>?
Get the month this period represents. Returns nil if no single month can be identified.
|
# File 'lib/timeboss/calendar/period.rb', line 70
|
#months ⇒ Array<Calendar::Month>
Get a list of months that fall within this period.
|
# File 'lib/timeboss/calendar/period.rb', line 66
|
#name ⇒ String
Get a simple representation of this period.
|
# File 'lib/timeboss/calendar/period.rb', line 18
|
#quarter(index = nil) ⇒ Array<Calendar::Quarter>?
Get the quarter this period represents. Returns nil if no single quarter can be identified.
|
# File 'lib/timeboss/calendar/period.rb', line 81
|
#quarters ⇒ Array<Calendar::Quarter>
Get a list of quarters that fall within this period.
|
# File 'lib/timeboss/calendar/period.rb', line 77
|
#start_date ⇒ Date
Get the start date of this period.
11 |
# File 'lib/timeboss/calendar/period.rb', line 11 delegate :start_date, to: :begin |
#title ⇒ String
Get a “pretty” representation of this period.
|
# File 'lib/timeboss/calendar/period.rb', line 22
|
#to_range ⇒ Range<Date, Date>
Express this period as a date range.
132 133 134 |
# File 'lib/timeboss/calendar/period.rb', line 132 def to_range @_to_range ||= start_date..end_date end |
#to_s ⇒ String
Get a stringified representation of this period.
30 31 32 33 34 35 36 |
# File 'lib/timeboss/calendar/period.rb', line 30 i[name title to_s].each do || define_method() do text = self.begin.public_send() text = "#{text} #{Parser::RANGE_DELIMITER} #{self.end.public_send(message)}" unless self.end == self.begin text end end |
#week(index = nil) ⇒ Array<Calendar::Week>?
Get the week this period represents. Returns nil if no single week can be identified.
|
# File 'lib/timeboss/calendar/period.rb', line 59
|
#weeks ⇒ Array<Calendar::Week>
Get a list of weeks that fall within this period.
|
# File 'lib/timeboss/calendar/period.rb', line 55
|
#year(index = nil) ⇒ Array<Calendar::Year>?
Get the year this period represents. Returns nil if no single year can be identified.
|
# File 'lib/timeboss/calendar/period.rb', line 103
|
#years ⇒ Array<Calendar::Year>
Get a list of years that fall within this period.
|
# File 'lib/timeboss/calendar/period.rb', line 99
|