Class: ShiftNote::User
Overview
An employee.
Instance Attribute Summary collapse
-
#birthday ⇒ Time
readonly
The user's birthday.
-
#email ⇒ String
readonly
The user's email.
-
#hire_day ⇒ Time?
readonly
The employee's hire date, nil if they don't have one set.
-
#id ⇒ Integer
readonly
This is the employee's ID.
-
#last_day ⇒ Time?
readonly
The employee's last day, nil if they don't have one (good).
-
#name ⇒ String
readonly
The employee's (legal) name.
-
#phones ⇒ Array<String>
readonly
An array containing the user's home and mobile phone numbers.
-
#positions ⇒ Array<String>
readonly
The positions this employee is working.
-
#raw ⇒ JSON
readonly
The raw data returned by ShiftNote.
-
#schedule_this_week ⇒ ScheduleThisWeek
readonly
The user's “Schedule This Week,” consider the return type for info.
Instance Method Summary collapse
-
#initialize(data) ⇒ User
constructor
A new instance of User.
-
#trade_shifts? ⇒ true, false
(also: #can_swap?)
Trading (or swapping) means the employee can trade shifts with other employees.
-
#trade_shifts_current_day? ⇒ true, false
Assuming trade_shifts? is true, this method returns if the user can trade shifts for the given day.
Methods inherited from Employee
Constructor Details
#initialize(data) ⇒ User
Returns a new instance of User.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/shiftnote/user.rb', line 3 def initialize(data) @raw = data @id = data['EmployeeId'] @name = data['EmployeeName'] @phones = { 'home' => data['HomePhone'], 'mobile' => data['MobilePhone'] } @email = data['Email'] @birthday = data['BirthDate'] ? Time.parse(data['BirthDate']) : nil @schedule_this_week = ShiftNote::ScheduleThisWeek.new(data['ScheduleThisWeekViewModel']) @trade_shifts = data['TradeShifts'] @trade_shifts_current_day = data['TradeShiftsCurrentDay'] @positions = data['ThisEmployeePositions'] @last_day = data['LastDay'] ? Time.parse(data['LastDay']) : nil @hire_day = data['HireDate'] ? Time.parse(data['HireDate']) : nil end |
Instance Attribute Details
#birthday ⇒ Time (readonly)
Returns the user's birthday.
37 38 39 |
# File 'lib/shiftnote/user.rb', line 37 def birthday @birthday end |
#email ⇒ String (readonly)
Returns the user's email.
34 35 36 |
# File 'lib/shiftnote/user.rb', line 34 def email @email end |
#hire_day ⇒ Time? (readonly)
Returns the employee's hire date, nil if they don't have one set.
65 66 67 |
# File 'lib/shiftnote/user.rb', line 65 def hire_day @hire_day end |
#id ⇒ Integer (readonly)
This is the employee's ID. Really has no use outside of Shiftnote internal data
23 24 25 |
# File 'lib/shiftnote/user.rb', line 23 def id @id end |
#last_day ⇒ Time? (readonly)
Returns the employee's last day, nil if they don't have one (good).
62 63 64 |
# File 'lib/shiftnote/user.rb', line 62 def last_day @last_day end |
#name ⇒ String (readonly)
The employee's (legal) name.
27 28 29 |
# File 'lib/shiftnote/user.rb', line 27 def name @name end |
#phones ⇒ Array<String> (readonly)
An array containing the user's home and mobile phone numbers
31 32 33 |
# File 'lib/shiftnote/user.rb', line 31 def phones @phones end |
#positions ⇒ Array<String> (readonly)
Returns the positions this employee is working.
59 60 61 |
# File 'lib/shiftnote/user.rb', line 59 def positions @positions end |
#raw ⇒ JSON (readonly)
Returns the raw data returned by ShiftNote.
68 69 70 |
# File 'lib/shiftnote/user.rb', line 68 def raw @raw end |
#schedule_this_week ⇒ ScheduleThisWeek (readonly)
The user's “Schedule This Week,” consider the return type for info
41 42 43 |
# File 'lib/shiftnote/user.rb', line 41 def schedule_this_week @schedule_this_week end |
Instance Method Details
#trade_shifts? ⇒ true, false Also known as: can_swap?
Trading (or swapping) means the employee can trade shifts with other employees.
45 46 47 |
# File 'lib/shiftnote/user.rb', line 45 def trade_shifts? @trade_shifts end |
#trade_shifts_current_day? ⇒ true, false
Assuming trade_shifts? is true, this method returns if the user can trade shifts for the given day. Where I work, this is false. Should've thought of that first, Billy.
54 55 56 |
# File 'lib/shiftnote/user.rb', line 54 def trade_shifts_current_day? @trade_shifts_current_day end |