Class: Date

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

Direct Known Subclasses

GBWorkDay::Date

Instance Method Summary collapse

Instance Method Details

#free?boolean

Check if it is a work day.

Returns:

  • (boolean)


34
35
36
# File 'lib/gb_work_day/core_ext/date.rb', line 34

def free?
  default_week.free_day? self
end

#minus_with_work_duration(other) ⇒ Object Also known as: -



14
15
16
17
18
19
20
21
22
# File 'lib/gb_work_day/core_ext/date.rb', line 14

def minus_with_work_duration(other)
  if GBWorkDay::Duration === other
    plus_with_work_duration(- other)
  elsif GBWorkDay::Date === other
    - (other - self)
  else
    minus_without_work_duration(other)
  end
end

#next_work_dayTime

Return next working day

Returns:



40
41
42
# File 'lib/gb_work_day/core_ext/date.rb', line 40

def next_work_day
  self + GBWorkDay::Duration.new(1, default_week)
end

#plus_with_work_duration(other) ⇒ Object Also known as: +



4
5
6
7
8
9
10
# File 'lib/gb_work_day/core_ext/date.rb', line 4

def plus_with_work_duration(other)
  if GBWorkDay::Duration === other
    other.since(self)
  else
    plus_without_work_duration(other)
  end
end

#work?boolean

Check if it is a work day.

Returns:

  • (boolean)


28
29
30
# File 'lib/gb_work_day/core_ext/date.rb', line 28

def work?
  default_week.work_day? self
end

#work_date(week = nil) ⇒ Object Also known as: to_work, to_work_date

Get date object for calculating working days

Parameters:

  • week (GBWorkDay::WorkWeek) (defaults to: nil)

    if not set, it will use week set globally. For more check GBWorkingDay::WorkWeek#current



47
48
49
# File 'lib/gb_work_day/core_ext/date.rb', line 47

def work_date(week=nil)
  GBWorkDay::Date.from_date self, week
end