class Daneel::User
Represents a generic user. Doesn’t have a room, because multiple rooms can contain the same user. The user’s unique identifier is supplied by the adapter, and only needs to be unique within the context of that adapter.
Attributes
data[RW]
id[R]
initials[RW]
name[R]
short_name[RW]
Public Class Methods
new(id, name, data = nil)
click to toggle source
# File lib/daneel/user.rb, line 10 def initialize(id, name, data = nil) @id, @name, @data = id, name, data # First, try to get initials from the upper-case letters @initials = name.gsub(/\P{Upper}/,'') # If that fails, just go with the first letter of each word @initials = name.gsub(/(?<!^|\s)./,'') if @initials.empty? # Short name is just the bit up to the first space @short_name = name.match(/^(\S+)/)[0] end
Public Instance Methods
to_s()
click to toggle source
# File lib/daneel/user.rb, line 21 def to_s [short_name, short_name.downcase, initials].sample end