class Blur::Channel
The Channel
class is used for encapsulating a channel and its properties.
Users inside the channel is stored in the {#channels} attribute.
Modes can be set for a channel, but Blur
is not {www.irc.org/tech_docs/005.html ISupport}-compliant yet.
@todo make so that channels and users belongs to the network, and not
like now where the user belongs to the channel, resulting in multiple user instances.
Attributes
@return [String] all the modes set on the channel.
@return [String] the channels name.
@return [Network] a reference to the network.
@return [String] the channels topic.
@return [Array] list of references to users in the channel.
Public Class Methods
Instantiate a user with a nickname, a network and a user list.
# File library/blur/channel.rb, line 27 def initialize name, network = nil @name = name @users = [] @modes = String.new @network = network end
Public Instance Methods
Convert it to a debug-friendly format.
# File library/blur/channel.rb, line 60 def inspect %{#<#{self.class.name}:0x#{self.object_id.to_s 16} @name=#{@name.inspect} @topic=#{@topic.inspect} @users=#{@users.inspect}} end
Merge the channels mode corresponding to the leading character (+ or -).
@param [String] modes the modes to merge with.
# File library/blur/channel.rb, line 37 def merge_modes modes addition = true modes.each_char do |char| case char when ?+ addition = true when ?- addition = false else addition ? @modes.concat(char) : @modes.delete!(char) end end end
Send a message to the channel.
@param [String] message the message to send.
# File library/blur/channel.rb, line 55 def say message @network.say self, message end
Get the channels name.
# File library/blur/channel.rb, line 71 def to_s @name end
Called when YAML attempts to save the object, which happens when a scripts cache contains this user and the script is unloaded.
# File library/blur/channel.rb, line 66 def to_yaml options = {} @name.to_yaml options end