class BBBEvents::Attendee

Constants

MODERATOR_ROLE
VIEWER_ROLE

Attributes

duration[RW]
engagement[RW]
id[RW]
joins[RW]
leaves[RW]
moderator[RW]
name[RW]
recent_talking_time[RW]

Public Class Methods

new(join_event) click to toggle source
# 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,
  }
end

Public Instance Methods

csv_row() click to toggle source
# File lib/bbbevents/attendee.rb, line 44
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/bbbevents/attendee.rb, line 35
def joined
  @joins.first
end
left() click to toggle source

Grab the last leave.

# File lib/bbbevents/attendee.rb, line 40
def left
  @leaves.last
end
moderator?() click to toggle source
# File lib/bbbevents/attendee.rb, line 30
def moderator?
  moderator
end
to_h() click to toggle source
# File lib/bbbevents/attendee.rb, line 61
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/bbbevents/attendee.rb, line 73
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/bbbevents/attendee.rb, line 86
def seconds_to_time(seconds)
  [seconds / 3600, seconds / 60 % 60, seconds % 60].map { |t| t.floor.to_s.rjust(2, "0") }.join(':')
end