Class: Weechat::IRC::Channel
- Inherits:
-
Object
- Object
- Weechat::IRC::Channel
show all
- Extended by:
- Properties
- Includes:
- Pointer
- Defined in:
- lib/weechat/channel.rb
Instance Attribute Summary collapse
Attributes included from Pointer
#ptr
Class Method Summary
collapse
Instance Method Summary
collapse
#all, #apply_rtransformation, #apply_transformation, #init_properties, #known_integer_properties, #known_properties, #known_string_properties, #mappings, #rtransformations, #settable_properties, #transformations, #type
Methods included from Pointer
#==, #hash, included, #inspect, #to_s
Constructor Details
#initialize(buffer) ⇒ Channel
Returns a new instance of Channel.
28
29
30
31
32
33
34
|
# File 'lib/weechat/channel.rb', line 28
def initialize(buffer)
@buffer = Buffer.from_ptr(buffer.to_s)
@ptr = @buffer.ptr
if not ["channel"].include?(@buffer.localvar_type)
raise Exception::NotAChannel, buffer.ptr
end
end
|
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
27
28
29
|
# File 'lib/weechat/channel.rb', line 27
def buffer
@buffer
end
|
Class Method Details
.all ⇒ Object
16
17
18
|
# File 'lib/weechat/channel.rb', line 16
def all
Weechat::Buffer.all.select {|b| b.channel?}.map{|b| b.channel}
end
|
.find(server, channel) ⇒ Object
20
21
22
23
24
|
# File 'lib/weechat/channel.rb', line 20
def find(server, channel)
server = server.name if server.respond_to?(:name)
channel = channel.name if channel.respond_to?(:name)
Weechat::Buffer.find("irc", "#{server}.#{channel}")
end
|
Instance Method Details
#command(*parts) ⇒ Object
Also known as:
send_command, exec, execute
67
68
69
|
# File 'lib/weechat/channel.rb', line 67
def command(*parts)
@buffer.command(*parts)
end
|
#get_infolist(*fields) ⇒ Object
36
37
38
39
|
# File 'lib/weechat/channel.rb', line 36
def get_infolist(*fields)
list = Weechat::Infolist.parse("irc_channel", "", server.name, {:buffer => [:pointer, @ptr]}, *fields)
list.empty? ? [{}] : list
end
|
#join(password = "") ⇒ Object
49
50
51
|
# File 'lib/weechat/channel.rb', line 49
def join(password = "")
@buffer.command("/join #{self.name} #{password}")
end
|
#nicks ⇒ Object
Also known as:
users
59
60
61
62
63
64
|
# File 'lib/weechat/channel.rb', line 59
def nicks
Weechat::Infolist.parse("irc_nick", "",
"#{self.server.name},#{self.name}").map {|user|
IRC::User.new(user.merge({:channel => self}))
}
end
|
#part(reason = "") ⇒ Object
45
46
47
|
# File 'lib/weechat/channel.rb', line 45
def part(reason="")
@buffer.command("/part #{self.name} #{reason}")
end
|
#rejoin(password = "") ⇒ Object
Also known as:
cycle
53
54
55
56
|
# File 'lib/weechat/channel.rb', line 53
def rejoin(password = "")
part(reason)
join(password)
end
|
#send(*text) ⇒ Object
Also known as:
privmsg, say
74
75
76
|
# File 'lib/weechat/channel.rb', line 74
def send(*text)
@buffer.send(*text)
end
|
#server ⇒ Object
41
42
43
|
# File 'lib/weechat/channel.rb', line 41
def server
IRC::Server.from_name(@buffer.localvar_server)
end
|