Class: AIXM::Component::Timesheet

Inherits:
AIXM::Component show all
Defined in:
lib/aixm/component/timesheet.rb

Overview

Timesheets define customized activity time windows.

AIXM supports only yearless dates whereas OFMX extends the model to accommodate years as well, therefore, the year part is ignored for AIXM.

Cheat Sheat in Pseudo Code:

timesheet = AIXM.timesheet(
  adjust_to_dst: Boolean
  dates: (AIXM.date..AIXM.date)
  days: (AIXM.day..AIXM..day)     # either: range of days
  day: AIXM.day (default: :any)   # or: single day
)
timesheet.times = (AIXM.time..AIXM_time)

Constant Summary collapse

DAYS =
{
  MON: :monday,
  TUE: :tuesday,
  WED: :wednesday,
  THU: :thursday,
  FRI: :friday,
  SAT: :saturday,
  SUN: :sunday,
  WD: :workday,
  PWD: :day_preceding_workday,
  AWD: :day_following_workday,
  LH: :holiday,
  PLH: :day_preceding_holiday,
  ALH: :day_following_holiday,
  ANY: :any
}
EVENTS =
{
  SR: :sunrise,
  SS: :sunset
}
PRECEDENCES =
{
  E: :first,
  L: :last
}

Instance Attribute Summary collapse

Attributes inherited from AIXM::Component

#meta

Instance Method Summary collapse

Methods included from AIXM::Concerns::HashEquality

#eql?, #hash

Methods included from AIXM::Concerns::XMLBuilder

#build_fragment, #to_uid, #to_xml

Methods included from AIXM::Concerns::Memoize

included, method

Constructor Details

#initialize(adjust_to_dst:, dates:, days: nil, day: AIXM::ANY_DAY) ⇒ Timesheet

See the cheat sheet for examples on how to create instances of this class.



87
88
89
90
91
92
93
94
# File 'lib/aixm/component/timesheet.rb', line 87

def initialize(adjust_to_dst:, dates:, days: nil, day: AIXM::ANY_DAY)
  self.adjust_to_dst, self.dates = adjust_to_dst, dates
  if days
    self.days = days
  else
    self.day = day
  end
end

Instance Attribute Details

#adjust_to_dst?Boolean #adjust_to_dst=(value) ⇒ Object

Note:

See the OFMX docs for how exactly this affects dates and times.

Whether to adjust to dayight savings time.

Overloads:

  • #adjust_to_dst?Boolean

    Returns:

    • (Boolean)
  • #adjust_to_dst=(value) ⇒ Object

    Parameters:

    • value (Boolean)


111
112
113
# File 'lib/aixm/component/timesheet.rb', line 111

def adjust_to_dst?
  @adjust_to_dst
end

#datesRange<AIXM::Schedule::Date> #dates=(value) ⇒ Object

Note:

Neither open beginning nor open ending is allowed.

Range of schedule dates for which this timesheet is active.

Overloads:



59
60
61
# File 'lib/aixm/component/timesheet.rb', line 59

def dates
  @dates
end

#dayAIXM::Schedule::Day #daysRange<AIXM::Schedule::Day> #day=(value) ⇒ Object #days=(value) ⇒ Object

Note:

Neither open beginning nor open ending is allowed.

Day or days for which this timesheet is active.

Overloads:



73
74
75
# File 'lib/aixm/component/timesheet.rb', line 73

def days
  @days
end

#timesRange<AIXM::Schedule::Time>? #times=(value) ⇒ Object

Note:

Either open beginning or open ending is allowed.

Range of schedule times for which this timesheet is active.

Overloads:



83
84
85
# File 'lib/aixm/component/timesheet.rb', line 83

def times
  @times
end

Instance Method Details

#adjust_to_dst?Boolean #adjust_to_dst=(value) ⇒ Object

Note:

See the OFMX docs for how exactly this affects dates and times.

Whether to adjust to dayight savings time.

Overloads:

  • #adjust_to_dst?Boolean

    Returns:

    • (Boolean)
  • #adjust_to_dst=(value) ⇒ Object

    Parameters:

    • value (Boolean)


111
112
113
# File 'lib/aixm/component/timesheet.rb', line 111

def adjust_to_dst?
  @adjust_to_dst
end

#dayObject



135
136
137
# File 'lib/aixm/component/timesheet.rb', line 135

def day
  @days unless @days.instance_of? Range
end

#day=(value) ⇒ Object



139
140
141
142
# File 'lib/aixm/component/timesheet.rb', line 139

def day=(value)
  fail(ArgumentError, 'invalid day') unless value.instance_of? AIXM::Schedule::Day
  @days = value
end

#inspectString

Returns:

  • (String)


97
98
99
# File 'lib/aixm/component/timesheet.rb', line 97

def inspect
  %Q(#<#{self.class} dates=#{dates.inspect}>)
end