class SARVEvents::Attendee
Constants
- MODERATOR_ROLE
- VIEWER_ROLE
Attributes
duration[RW]
engagement[RW]
ext_user_id[RW]
id[RW]
joins[RW]
leaves[RW]
moderator[RW]
name[RW]
recent_talking_time[RW]
sessions[RW]
Public Class Methods
new(join_event)
click to toggle source
# File lib/sarvevents/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
Public Instance Methods
csv_row()
click to toggle source
# File lib/sarvevents/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()
click to toggle source
Grab the initial join.
# File lib/sarvevents/attendee.rb, line 39 def joined @joins.first end
left()
click to toggle source
Grab the last leave.
# File lib/sarvevents/attendee.rb, line 44 def left @leaves.last end
moderator?()
click to toggle source
# File lib/sarvevents/attendee.rb, line 34 def moderator? moderator end
to_h()
click to toggle source
# File lib/sarvevents/attendee.rb, line 65 def to_h hash = {} instance_variables.each { |var| hash[var[1..-1]] = instance_variable_get(var) } # Convert recent_talking_time to human readable time if hash["recent_talking_time"] > 0 hash["recent_talking_time"] = Time.at(hash["recent_talking_time"]) else hash["recent_talking_time"] = "" end hash end
to_json()
click to toggle source
# File lib/sarvevents/attendee.rb, line 77 def to_json hash = {} instance_variables.each { |var| hash[var[1..-1]] = instance_variable_get(var) } if hash["recent_talking_time"] > 0 hash["recent_talking_time"] = Time.at(hash["recent_talking_time"]) else hash["recent_talking_time"] = "" end hash.to_json end
Private Instance Methods
seconds_to_time(seconds)
click to toggle source
# File lib/sarvevents/attendee.rb, line 90 def seconds_to_time(seconds) [seconds / 3600, seconds / 60 % 60, seconds % 60].map { |t| t.floor.to_s.rjust(2, "0") }.join(':') end