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

modes[RW]

@return [String] all the modes set on the channel.

name[RW]

@return [String] the channels name.

network[RW]

@return [Network] a reference to the network.

topic[RW]

@return [String] the channels topic.

users[RW]

@return [Array] list of references to users in the channel.

Public Class Methods

new(name, network = nil) click to toggle source

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

inspect() click to toggle source

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_modes(modes) click to toggle source

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
say(message) click to toggle source

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
to_s() click to toggle source

Get the channels name.

# File library/blur/channel.rb, line 71
def to_s
  @name
end
to_yaml(options = {}) click to toggle source

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