class ShiftNote::User

An employee.

Attributes

birthday[R]

@return [Time] the user's birthday

email[R]

@return [String] the user's email.

hire_day[R]

@return [Time, nil] the employee's hire date, nil if they don't have one set

id[R]

This is the employee's ID. Really has no use outside of Shiftnote internal data @return [Integer] the employee's internal ID

last_day[R]

@return [Time, nil] the employee's last day, nil if they don't have one (good)

name[R]

The employee's (legal) name. @return [String] the employee's name

phones[R]

An array containing the user's home and mobile phone numbers @return [Array<String>] the user's phone numbers.

positions[R]

@return [Array<String>] the positions this employee is working.

raw[R]

@return [JSON] the raw data returned by ShiftNote

schedule_this_week[R]

The user's “Schedule This Week,” consider the return type for info @return [ScheduleThisWeek]

Public Class Methods

new(data) click to toggle source
# 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

Public Instance Methods

can_swap?()
Alias for: trade_shifts?
trade_shifts?() click to toggle source

Trading (or swapping) means the employee can trade shifts with other employees. @return [true, false] if this employee can trade (or swap) shifts at all.

# File lib/shiftnote/user.rb, line 45
def trade_shifts?
  @trade_shifts
end
Also aliased as: can_swap?
trade_shifts_current_day?() click to toggle source

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. @return [true, false] if this employee can trade shifts for today's shifts.

# File lib/shiftnote/user.rb, line 54
def trade_shifts_current_day?
  @trade_shifts_current_day
end