Class: ShiftNote::DaysOfWeekShift
- Inherits:
-
Object
- Object
- ShiftNote::DaysOfWeekShift
- Defined in:
- lib/shiftnote/days_of_week_shift.rb
Overview
A specific day of a schedule.
Instance Attribute Summary collapse
-
#date ⇒ Time
readonly
The day.
-
#raw ⇒ JSON
readonly
The raw data returned by ShiftNote.
Instance Method Summary collapse
-
#amount_of_shifts ⇒ Integer
The amount shifts this employee is working on this day.
-
#first_shift ⇒ Shift
The first shift this employee is working on this day.
-
#initialize(data) ⇒ DaysOfWeekShift
constructor
A new instance of DaysOfWeekShift.
-
#shifts ⇒ Array<Shift>
The shifts this employee is working on this day.
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
#date ⇒ Time (readonly)
Returns the day.
10 11 12 |
# File 'lib/shiftnote/days_of_week_shift.rb', line 10 def date @date end |
#raw ⇒ JSON (readonly)
Returns 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_shifts ⇒ Integer
Returns 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_shift ⇒ Shift
Returns 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 |
#shifts ⇒ Array<Shift>
Returns 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 |