Class: AIXM::Component::Timetable

Inherits:
AIXM::Component show all
Includes:
AIXM::Concerns::Association, AIXM::Concerns::Remarks
Defined in:
lib/aixm/component/timetable.rb

Overview

Timetables define activity time windows.

Cheat Sheat in Pseudo Code:

timetable = AIXM.timetable(
  code: String or Symbol (default: :timesheet)
)
timetable.add_timesheet(AIXM.timesheet)
timetable.remarks = String or nil

Shortcuts:

  • AIXM::H24 - continuous, all day and all night

  • AIXM::H_RE - pattern matching working hour codes

Constant Summary collapse

CODES =
{
  TIMSH: :timesheet,          # attached timesheet
  H24: :continuous,           # all day and all night
  HJ: :sunrise_to_sunset,     # all day
  HN: :sunset_to_sunrise,     # all night
  HX: :unspecified,
  HO: :operational_request,   # on request only
  NOTAM: :notam,              # see NOTAM
  OTHER: :other               # specify in remarks
}.freeze

Instance Attribute Summary collapse

Attributes included from AIXM::Concerns::Remarks

#remarks

Attributes inherited from AIXM::Component

#meta

Instance Method Summary collapse

Methods included from AIXM::Concerns::Association

included

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(code: :timesheet) ⇒ Timetable

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


47
48
49
# File 'lib/aixm/component/timetable.rb', line 47

def initialize(code: :timesheet)
  self.code = code
end

Instance Attribute Details

#codeSymbol #code=(value) ⇒ Object

Timetable code

Overloads:

  • #codeSymbol

    Returns any of CODES.

    Returns:

    • (Symbol)

      any of CODES

  • #code=(value) ⇒ Object

    Parameters:

    • value (Symbol)

      any of CODES


63
64
65
# File 'lib/aixm/component/timetable.rb', line 63

def code
  timesheets.any? ? :timesheet : @code
end

Instance Method Details

#add_timesheet(timesheet) ⇒ Object

Note:

The #code is forced to :timesheet once at least one timesheet has been added.

Parameters:


43
# File 'lib/aixm/component/timetable.rb', line 43

has_many :timesheets

#inspectString

Returns:

  • (String)

52
53
54
# File 'lib/aixm/component/timetable.rb', line 52

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

#timesheetsArray<AIXM::Component::Timesheet>

Returns timesheets attached to this timetable.

Returns:


43
# File 'lib/aixm/component/timetable.rb', line 43

has_many :timesheets