Class: Participle::DA::Room

Inherits:
Object
  • Object
show all
Defined in:
lib/room.rb

Overview

Any room that the bot is connected to.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Room) initialize(name)



30
31
32
33
34
35
# File 'lib/room.rb', line 30

def initialize name
  @name           = name
  @name_formatted = name =~ /:/ ? "pchat:#{name}" : "chat:#{name}"
  @members        = {}
  @privclasses    = {}
end

Instance Attribute Details

- (Hash<Symbol, OpenStruct>) members



21
22
23
# File 'lib/room.rb', line 21

def members
  @members
end

- (String) name (readonly)



24
25
26
# File 'lib/room.rb', line 24

def name
  @name
end

- (String) name_formatted (readonly)



27
28
29
# File 'lib/room.rb', line 27

def name_formatted
  @name_formatted
end

- (Hash<Symbol, Privclass>) privclasses



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

def privclasses
  @privclasses
end

- (String) title



15
16
17
# File 'lib/room.rb', line 15

def title
  @title
end

- (String) topic



12
13
14
# File 'lib/room.rb', line 12

def topic
  @topic
end

Instance Method Details

- (Boolean) ===(item)

Is the room's name item?



101
102
103
# File 'lib/room.rb', line 101

def ===(item)
  @name == item
end

- (Hash<Symbol, OpenStruct>) addmember(member)

Add a member.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/room.rb', line 40

def addmember member
  return if @members[member.param.to_sym]
  @members[member.param.to_sym] = OpenStruct.new
  member.each{|k,v|
    if k == :pc
      @members[member.param.to_sym].privclass = @privclasses[v.to_sym]
    else
      @members[member.param.to_sym].send("#{k}=".to_sym, v)
    end
    @members[member.param.to_sym].connections = 1
  }
  @members[member.param.to_sym].level = begin; Privilege.find_by_name(member.param).level; rescue; 1; end
  @members[member.param.to_sym].nick = member.param
  @members
end

- (Hash<Symbol, Privclass>) addprivclass(name, level)

Add a privclass.



74
75
76
77
78
# File 'lib/room.rb', line 74

def addprivclass name, level
  return if @privclasses[name]
  @privclasses[name.to_sym] = Privclass.new(name, level.to_i)
  @privclasses
end

- (Hash<Symbol, OpenStruct>) delmember(member)

Remove a member.



59
60
61
62
# File 'lib/room.rb', line 59

def delmember member
  @members.delete(member.to_sym)
  @members
end

- (Hash) delmembers

Remove all members.



66
67
68
# File 'lib/room.rb', line 66

def delmembers
  @members = {}
end

- (Hash<Symbol, Privclass>) delprivclass(name)

Remove a privclass.



89
90
91
92
# File 'lib/room.rb', line 89

def delprivclass name
  @privclasses.delete(name.to_sym)
  @privclasses
end

- (Hash) delprivclasses

Remove all privclasses.



82
83
84
# File 'lib/room.rb', line 82

def delprivclasses
  @privclasses = {}
end

- (String) to_s



95
96
97
# File 'lib/room.rb', line 95

def to_s
  "#<#{@name}:DA::Room privclasses=[#{@privclasses.keys.join(", ")}] members=#{@members.count}>"
end