Class: Fantasy::User::User

Inherits:
Object
  • Object
show all
Defined in:
lib/fantasy-irc/users.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, connection) ⇒ User

Returns a new instance of User.



40
41
42
43
44
45
46
47
48
49
# File 'lib/fantasy-irc/users.rb', line 40

def initialize name, connection
    if not connection.respond_to?(:send) then
        raise "Connection class needs to be able to respond to :send"
    end

    @name = name
    puts "New User #{self.object_id} with name #{@name}"
    @connection = connection
    @rooms = Array::Unique.new
end

Instance Attribute Details

#maskObject (readonly)

Returns the value of attribute mask.



37
38
39
# File 'lib/fantasy-irc/users.rb', line 37

def mask
  @mask
end

#nameObject (readonly)

Returns the value of attribute name.



37
38
39
# File 'lib/fantasy-irc/users.rb', line 37

def name
  @name
end

#roomsObject

Returns the value of attribute rooms.



38
39
40
# File 'lib/fantasy-irc/users.rb', line 38

def rooms
  @rooms
end

Instance Method Details

#ignore!Object

Ignoring



68
69
70
# File 'lib/fantasy-irc/users.rb', line 68

def ignore!
    @ignored = true
end

#ignored?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/fantasy-irc/users.rb', line 76

def ignored?
    !!@ignored
end

#loginObject



62
63
64
# File 'lib/fantasy-irc/users.rb', line 62

def 
    self.name
end

#resetObject

resets user information



52
53
54
55
# File 'lib/fantasy-irc/users.rb', line 52

def reset
    puts "Resetting user #{self.object_id} with name #{@name}"
    @rooms = Array::Unique.new
end

#say(message) ⇒ Object



57
58
59
60
# File 'lib/fantasy-irc/users.rb', line 57

def say message
    @connection.send('PRIVMSG '+@name+' :'+message)
    return self
end

#to_sObject



81
82
83
# File 'lib/fantasy-irc/users.rb', line 81

def to_s
    "#{@name}"
end

#unignore!Object



72
73
74
# File 'lib/fantasy-irc/users.rb', line 72

def unignore!
    @ignored = false
end