Class: ShiftNote::DaysOfWeekShift

Inherits:
Object
  • Object
show all
Defined in:
lib/shiftnote/days_of_week_shift.rb

Overview

A specific day of a schedule.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ DaysOfWeekShift

Returns a new instance of DaysOfWeekShift.


3
4
5
6
7
# File 'lib/shiftnote/days_of_week_shift.rb', line 3

def initialize(data)
  @raw = data
  @date = Time.parse(data['ShiftDate'])
  @raw_shifts = data['Shifts']
end

Instance Attribute Details

#dateTime (readonly)

Returns the day.

Returns:

  • (Time)

    the day


10
11
12
# File 'lib/shiftnote/days_of_week_shift.rb', line 10

def date
  @date
end

#rawJSON (readonly)

Returns the raw data returned by ShiftNote.

Returns:

  • (JSON)

    the raw data returned by ShiftNote.


32
33
34
# File 'lib/shiftnote/days_of_week_shift.rb', line 32

def raw
  @raw
end

Instance Method Details

#amount_of_shiftsInteger

Returns the amount shifts this employee is working on this day.

Returns:

  • (Integer)

    the amount shifts this employee is working on this day.


22
23
24
# File 'lib/shiftnote/days_of_week_shift.rb', line 22

def amount_of_shifts
  @raw_shifts.length
end

#first_shiftShift

Returns the first shift this employee is working on this day.

Returns:

  • (Shift)

    the first shift this employee is working on this day.


27
28
29
# File 'lib/shiftnote/days_of_week_shift.rb', line 27

def first_shift
  ShiftNote::Shift.new(@raw_shifts.first)
end

#shiftsArray<Shift>

Returns the shifts this employee is working on this day.

Returns:

  • (Array<Shift>)

    the shifts this employee is working on this day.


13
14
15
16
17
18
19
# File 'lib/shiftnote/days_of_week_shift.rb', line 13

def shifts
  shifts = []
  @raw_shifts.each do |e|
    shifts.push ShiftNote::Shift.new(e)
  end
  shifts
end