class Time

Public Instance Methods

+(other)
Also aliased as: plus_without_work_duration
-(other)
Also aliased as: minus_without_work_duration
free?(week = default_week) click to toggle source

Check if it is a work day. @return [boolean]

# File lib/gb_work_day/core_ext/time.rb, line 35
def free?(week = default_week)
  week.free_day? self
end
minus_with_work_duration(other) click to toggle source
# File lib/gb_work_day/core_ext/time.rb, line 14
def minus_with_work_duration(other)
  if GBWorkDay::Duration === other
    plus_with_work_duration(-other)
  elsif GBWorkDay::Time === other
    - (other - self)
  else
    minus_without_work_duration(other)
  end
end
Also aliased as: -
minus_without_work_duration(other)
Alias for: -
next_work_day(week = default_week) click to toggle source

Return next working day @return [Time]

# File lib/gb_work_day/core_ext/time.rb, line 41
def next_work_day(week = default_week)
  if week.free_day? self
    self.beginning_of_week + 7.days
  else
    self + GBWorkDay::Duration.new(1, week)
  end
end
plus_with_work_duration(other) click to toggle source
# File lib/gb_work_day/core_ext/time.rb, line 4
def plus_with_work_duration(other)
  if GBWorkDay::Duration === other
    other.since(self)
  else
    plus_without_work_duration(other)
  end
end
Also aliased as: +
plus_without_work_duration(other)
Alias for: +
previous_work_day(week = default_week) click to toggle source

Return previous working day @return [Time]

# File lib/gb_work_day/core_ext/time.rb, line 51
def previous_work_day(week = default_week)
  if week.free_day? self
    next_work_day(week) - (week.free_days_per_week + 1).days
  else
    self - GBWorkDay::Duration.new(1, week)
  end
end
to_work(week = nil)
Alias for: work_time
to_work_time(week = nil)
Alias for: work_time
work?(week = default_week) click to toggle source

Check if it is a work day. @return [boolean]

# File lib/gb_work_day/core_ext/time.rb, line 29
def work?(week = default_week)
  week.work_day? self
end
work_time(week = nil) click to toggle source

Get time object for calculating working days

@param week [GBWorkDay::WorkWeek] if not set, it will use week set globally. For more check {GBWorkingDay::WorkWeek#current}

# File lib/gb_work_day/core_ext/time.rb, line 62
def work_time(week = nil)
  GBWorkDay::Time.from_time self, week
end
Also aliased as: to_work, to_work_time

Private Instance Methods

default_week() click to toggle source

@return [GBWorkDay::WorkWeek]

# File lib/gb_work_day/core_ext/time.rb, line 71
def default_week
  GBWorkDay::WorkWeek.current
end