Class: BBBEvents::Attendee
- Inherits:
-
Object
- Object
- BBBEvents::Attendee
- Defined in:
- lib/bbbevents/attendee.rb
Constant Summary collapse
- MODERATOR_ROLE =
"MODERATOR"
- VIEWER_ROLE =
"VIEWER"
Instance Attribute Summary collapse
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#engagement ⇒ Object
Returns the value of attribute engagement.
-
#ext_user_id ⇒ Object
Returns the value of attribute ext_user_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#joins ⇒ Object
Returns the value of attribute joins.
-
#leaves ⇒ Object
Returns the value of attribute leaves.
-
#moderator ⇒ Object
Returns the value of attribute moderator.
-
#name ⇒ Object
Returns the value of attribute name.
-
#recent_talking_time ⇒ Object
Returns the value of attribute recent_talking_time.
-
#sessions ⇒ Object
Returns the value of attribute sessions.
Instance Method Summary collapse
- #as_json ⇒ Object
- #csv_row ⇒ Object
-
#initialize(join_event) ⇒ Attendee
constructor
A new instance of Attendee.
-
#joined ⇒ Object
Grab the initial join.
-
#left ⇒ Object
Grab the last leave.
- #moderator? ⇒ Boolean
- #to_h ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(join_event) ⇒ Attendee
Returns a new instance of Attendee.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bbbevents/attendee.rb', line 8 def initialize(join_event) @id = join_event["userId"] @ext_user_id = join_event["externalUserId"] @name = join_event["name"] @moderator = (join_event["role"] == MODERATOR_ROLE) @joins = [] @leaves = [] @duration = 0 @recent_talking_time = 0 @engagement = { chats: 0, talks: 0, raisehand: 0, emojis: 0, poll_votes: 0, talk_time: 0, } # A hash of join and lefts arrays for each internal user id # { "w_5lmcgjboagjc" => { :joins => [], :lefts => []}} @sessions = Hash.new end |
Instance Attribute Details
#duration ⇒ Object
Returns the value of attribute duration.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def duration @duration end |
#engagement ⇒ Object
Returns the value of attribute engagement.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def engagement @engagement end |
#ext_user_id ⇒ Object
Returns the value of attribute ext_user_id.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def ext_user_id @ext_user_id end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def id @id end |
#joins ⇒ Object
Returns the value of attribute joins.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def joins @joins end |
#leaves ⇒ Object
Returns the value of attribute leaves.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def leaves @leaves end |
#moderator ⇒ Object
Returns the value of attribute moderator.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def moderator @moderator end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def name @name end |
#recent_talking_time ⇒ Object
Returns the value of attribute recent_talking_time.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def recent_talking_time @recent_talking_time end |
#sessions ⇒ Object
Returns the value of attribute sessions.
3 4 5 |
# File 'lib/bbbevents/attendee.rb', line 3 def sessions @sessions end |
Instance Method Details
#as_json ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/bbbevents/attendee.rb', line 80 def as_json { id: @id, ext_user_id: @ext_user_id, name: @name, moderator: @moderator, joins: @joins.map { |join| BBBEvents.format_datetime(join) }, leaves: @leaves.map { |leave| BBBEvents.format_datetime(leave) }, duration: @duration, recent_talking_time: @recent_talking_time > 0 ? BBBEvents.format_datetime(Time.at(@recent_talking_time)) : '', engagement: @engagement, sessions: @sessions.map { |key, session| { joins: session[:joins].map { |join| join.merge({ timestamp: BBBEvents.format_datetime(join[:timestamp])}) }, lefts: session[:lefts].map { |leave| leave.merge({ timestamp: BBBEvents.format_datetime(leave[:timestamp])}) } } } } end |
#csv_row ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bbbevents/attendee.rb', line 48 def csv_row e = @engagement [ @name, @moderator, e[:chats], e[:talks], e[:emojis], e[:poll_votes], e[:raisehand], seconds_to_time(@engagement[:talk_time]), joined.strftime(DATE_FORMAT), left.strftime(DATE_FORMAT), seconds_to_time(@duration), ].map(&:to_s) end |
#joined ⇒ Object
Grab the initial join.
39 40 41 |
# File 'lib/bbbevents/attendee.rb', line 39 def joined @joins.first end |
#left ⇒ Object
Grab the last leave.
44 45 46 |
# File 'lib/bbbevents/attendee.rb', line 44 def left @leaves.last end |
#moderator? ⇒ Boolean
34 35 36 |
# File 'lib/bbbevents/attendee.rb', line 34 def moderator? moderator end |
#to_h ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/bbbevents/attendee.rb', line 65 def to_h { id: @id, ext_user_id: @ext_user_id, name: @name, moderator: @moderator, joins: @joins, leaves: @leaves, duration: @duration, recent_talking_time: @recent_talking_time > 0 ? Time.at(@recent_talking_time) : '', engagement: @engagement, sessions: @sessions, } end |
#to_json ⇒ Object
99 100 101 |
# File 'lib/bbbevents/attendee.rb', line 99 def to_json JSON.generate(as_json) end |