Class: Weechat::IRC::User

Inherits:
Object
  • Object
show all
Defined in:
lib/weechat/irc/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ User

FIXME make users server agnostic



13
14
15
16
17
18
19
# File 'lib/weechat/irc/user.rb', line 13

def initialize(args = {})
  @name = args[:name]
  @identifier = IRC::Identifier.new(args[:host])
  @flags, @color, @channel = args.values_at(:flags, :color, :channel)
  # @flags, @color = args.values_at(:flags, :color)
  @server = @channel.server
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel



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

def channel
  @channel
end

#colorObject (readonly)

Returns the value of attribute color



7
8
9
# File 'lib/weechat/irc/user.rb', line 7

def color
  @color
end

#flagsObject (readonly)

Returns the value of attribute flags



6
7
8
# File 'lib/weechat/irc/user.rb', line 6

def flags
  @flags
end

#hostObject (readonly)

Returns the value of attribute host



5
6
7
# File 'lib/weechat/irc/user.rb', line 5

def host
  @host
end

#nameObject (readonly)

Returns the value of attribute name



4
5
6
# File 'lib/weechat/irc/user.rb', line 4

def name
  @name
end

#serverObject (readonly)

Returns the value of attribute server



9
10
11
# File 'lib/weechat/irc/user.rb', line 9

def server
  @server
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



28
29
30
# File 'lib/weechat/irc/user.rb', line 28

def ==(other)
  @name == other.name && @host == other.host #&& @channel == other.channel
end

#banObject



74
75
76
# File 'lib/weechat/irc/user.rb', line 74

def ban
  @channel.exec("/ban #@name")
end

#channelsObject



42
43
44
# File 'lib/weechat/irc/user.rb', line 42

def channels
  whois { |w| yield(w.channels) if block_given? }
end

#dehalfopObject



62
63
64
# File 'lib/weechat/irc/user.rb', line 62

def dehalfop
  @channel.exec("/dehalfop #@name")
end

#deopObject



58
59
60
# File 'lib/weechat/irc/user.rb', line 58

def deop
  @channel.exec("/deop #@name")
end

#devoiceObject



66
67
68
# File 'lib/weechat/irc/user.rb', line 66

def devoice
  @channel.exec("/devoice #@name")
end

#halfopObject



50
51
52
# File 'lib/weechat/irc/user.rb', line 50

def halfop
  @channel.exec("/halfop #@name")
end

#kick(reason = "") ⇒ Object



70
71
72
# File 'lib/weechat/irc/user.rb', line 70

def kick(reason="")
  @channel.exec("/kick #@name #{reason}")
end

#kickban(reason = "") ⇒ Object



82
83
84
85
# File 'lib/weechat/irc/user.rb', line 82

def kickban(reason="")
  kick(reason)
  ban
end

#opObject



46
47
48
# File 'lib/weechat/irc/user.rb', line 46

def op
  @channel.exec("/op #@name")
end

#real_nameObject



38
39
40
# File 'lib/weechat/irc/user.rb', line 38

def real_name
  whois { |w| yield(w.real_name) if block_given? }
end

#unbanObject



78
79
80
# File 'lib/weechat/irc/user.rb', line 78

def unban
  @channel.exec("/unban #@name")
end

#voiceObject



54
55
56
# File 'lib/weechat/irc/user.rb', line 54

def voice
  @channel.exec("/voice #@name")
end

#whoisObject



34
35
36
# File 'lib/weechat/irc/user.rb', line 34

def whois
  Weechat::IRC::Whois.new(self) { |w| yield(w) if block_given? }
end