Class: Rave::Models::User

Inherits:
Component show all
Defined in:
lib/models/user.rb

Overview

A wave client, acting as a wave creator, blip contributor and/or a wavelet participant.

Direct Known Subclasses

Robot

Constant Summary collapse

ROBOT_PATTERN =

:nodoc:

/@appspot\.com$/
NOBODY_ID =

:nodoc: Used as a default in certain circumstances.

"@@@nobody@@@"

Constants inherited from Component

Component::GENERATED_PATTERN, Component::GENERATED_PREFIX

Instance Attribute Summary

Attributes inherited from Component

#context

Instance Method Summary collapse

Methods inherited from Component

#id, #unique_id

Methods included from Rave::Mixins::Logger

#logger

Constructor Details

#initialize(options = {}) ⇒ User

  • :id

  • :name

  • :profile_url

  • :image_url

  • :context



32
33
34
35
36
37
38
# File 'lib/models/user.rb', line 32

def initialize(options = {}) # :nodoc:
  options[:id].downcase! if options[:id]
  super(options)
  @name = options[:name]
  @profile_url = options[:profile_url] || ''
  @image_url = options[:image_url] || ''
end

Instance Method Details

#generated?Boolean

Unlike other components, Users are never generated [Boolean].

Returns:

  • (Boolean)


23
24
25
# File 'lib/models/user.rb', line 23

def generated? # :nodoc:
  false
end

#image_urlObject

Url link to the image of the User [String]. NOTE: Due to a limitation in Wave, for all users except the local robot the url will be empty.



18
19
20
# File 'lib/models/user.rb', line 18

def image_url # :nodoc:
  @image_url.dup
end

#nameObject

Printable name of the User [String]. NOTE: Due to a limitation in Wave, for all users except the local robot the name is the same as the @id.



43
44
45
# File 'lib/models/user.rb', line 43

def name # :nodoc:
  @name || @id
end

#profile_urlObject

Url link to the profile of the User [String]. NOTE: Due to a limitation in Wave, for all users except the local robot the url will be empty.



11
12
13
# File 'lib/models/user.rb', line 11

def profile_url # :nodoc:
  @profile_url.dup
end

#robot?Boolean

Is the User a robot client rather than a human client? [Boolean]

Returns:

  • (Boolean)


48
49
50
# File 'lib/models/user.rb', line 48

def robot? # :nodoc:
  not (@id =~ ROBOT_PATTERN).nil?
end

#to_jsonObject

:nodoc:



57
58
59
# File 'lib/models/user.rb', line 57

def to_json # :nodoc:
  @id.to_json
end

#to_sObject

Convert to string [String]



53
54
55
# File 'lib/models/user.rb', line 53

def to_s
  @id
end