Class: RBZK::Attendance

Inherits:
Object
  • Object
show all
Defined in:
lib/rbzk/attendance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id, timestamp, status, punch, uid) ⇒ Attendance

Returns a new instance of Attendance.



7
8
9
10
11
12
13
# File 'lib/rbzk/attendance.rb', line 7

def initialize(user_id, timestamp, status, punch, uid)
  @user_id = user_id
  @timestamp = timestamp
  @status = status
  @punch = punch
  @uid = uid
end

Instance Attribute Details

#punchObject

Returns the value of attribute punch.



5
6
7
# File 'lib/rbzk/attendance.rb', line 5

def punch
  @punch
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/rbzk/attendance.rb', line 5

def status
  @status
end

#timestampObject

Returns the value of attribute timestamp.



5
6
7
# File 'lib/rbzk/attendance.rb', line 5

def timestamp
  @timestamp
end

#uidObject

Returns the value of attribute uid.



5
6
7
# File 'lib/rbzk/attendance.rb', line 5

def uid
  @uid
end

#user_idObject

Returns the value of attribute user_id.



5
6
7
# File 'lib/rbzk/attendance.rb', line 5

def user_id
  @user_id
end

Instance Method Details

#check_in?Boolean

Helper predicate for check-in (punch==0)

Returns:

  • (Boolean)


16
17
18
# File 'lib/rbzk/attendance.rb', line 16

def check_in?
  @punch == 0
end

#check_out?Boolean

Helper predicate for check-out (punch==1)

Returns:

  • (Boolean)


21
22
23
# File 'lib/rbzk/attendance.rb', line 21

def check_out?
  @punch == 1
end

#punch_nameObject

Human readable punch name (0=Check In, 1=Check Out)



26
27
28
29
30
31
32
# File 'lib/rbzk/attendance.rb', line 26

def punch_name
  case @punch
  when 0 then 'Check In'
  when 1 then 'Check Out'
  else "Punch (#{@punch})"
  end
end

#to_sObject



34
35
36
# File 'lib/rbzk/attendance.rb', line 34

def to_s
  "#{@user_id} #{@timestamp} #{@status} #{@punch} #{@uid}"
end