Class: CamperVan::User

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/camper_van/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#irc_name, #stringify_keys

Constructor Details

#initialize(user) ⇒ User

Public: create a new user from a campfire user definition.

Initializes the user’s fields based on the campfire user info.



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/camper_van/user.rb', line 48

def initialize(user)
  @id = user.id
  @name = user.name
  if user.email_address
    @account, @server = user.email_address.split("@")
  else
    @account = @server = "unknown"
  end
  @nick = irc_name user.name
  @idle = false
  @admin = user.admin
end

Instance Attribute Details

#accountObject (readonly)

Public: the user’s unix account name for user@host pairs in irc, mapped from the user’s email address



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

def 
  @account
end

#admin=(value) ⇒ Object (writeonly)

Public: set the user’s admin state

admin - true/false



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

def admin=(value)
  @admin = value
end

#idObject (readonly)

Public: the user’s campfire id



8
9
10
# File 'lib/camper_van/user.rb', line 8

def id
  @id
end

#idle=(value) ⇒ Object (writeonly)

Public: set the user’s idle state.

is_idle - true/false



33
34
35
# File 'lib/camper_van/user.rb', line 33

def idle=(value)
  @idle = value
end

#nameObject (readonly)

Public: the user’s campfire name



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

def name
  @name
end

#nickObject (readonly)

Public: the user’s irc nick



14
15
16
# File 'lib/camper_van/user.rb', line 14

def nick
  @nick
end

#serverObject (readonly)

Public: the user’s unix server name for user@host pairs in irc, mapped from the user’s email address



22
23
24
# File 'lib/camper_van/user.rb', line 22

def server
  @server
end

Instance Method Details

#admin?Boolean

Public: whether or not the user is an admin

Returns:

  • (Boolean)


36
37
38
# File 'lib/camper_van/user.rb', line 36

def admin?
  @admin
end

#idle?Boolean

Public: whether the user is idle or not. Updated by campfire Idle/Unidle messages

Returns:

  • (Boolean)


26
27
28
# File 'lib/camper_van/user.rb', line 26

def idle?
  @idle
end