Class: GBWorkDay::Date

Inherits:
Date
  • Object
show all
Defined in:
lib/gb_work_day/helpers/date.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Date

#free?, #minus_with_work_duration, #next_work_day, #plus_with_work_duration, #previous_work_day, #work?, #work_date

Instance Attribute Details

#work_weekObject

Returns the value of attribute work_week.



4
5
6
# File 'lib/gb_work_day/helpers/date.rb', line 4

def work_week
  @work_week
end

Class Method Details

.from_date(date, work_week = nil) ⇒ Object

Create GBWorkingDay::Date object from a given Date object. Copy constructor.

Parameters:



26
27
28
29
30
# File 'lib/gb_work_day/helpers/date.rb', line 26

def from_date(date, work_week = nil)
  new_date = self.jd(date.jd)
  new_date.work_week = work_week if work_week
  new_date
end

Instance Method Details

#-(other) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/gb_work_day/helpers/date.rb', line 6

def -(other)
  if other.is_a?(::Date) || other.is_a?(::Time)
    Interval.new(other, self, week: self.work_week).work_days
  else
    super
  end
end