Parent

Class/Module Index [+]

Quicksearch

Cinch::Mask

This class represents masks, which are primarily used for bans.

Attributes

host[R]

@return [String]

mask[R]

@return [String]

nick[R]

@return [String]

user[R]

@return [String]

Public Class Methods

from(target) click to toggle source

@param [String, mask] @return [target] if already a Mask @return [Mask] @version 2.0.0

# File lib/cinch/mask.rb, line 57
def self.from(target)
  return target if target.is_a?(self)

  if target.respond_to?(:mask)
    mask = target.mask
  else
    mask = Mask.new(target.to_s)
  end

  return mask
end
new(mask) click to toggle source

@version 1.1.2 @param [String] mask

# File lib/cinch/mask.rb, line 15
def initialize(mask)
  @mask = mask
  @nick, @user, @host = mask.match(/(.+)!(.+)@(.+)/)[1..-1]
  @regexp = Regexp.new("^" + Regexp.escape(mask).gsub("\\*", ".*").gsub("\\?", ".?") + "$")
end

Public Instance Methods

==(other) click to toggle source

@return [Boolean] @since 1.1.0

# File lib/cinch/mask.rb, line 23
def ==(other)
  other.respond_to?(:mask) && other.mask == @mask
end
=~(target) click to toggle source
Alias for: match
eql?(other) click to toggle source

@return [Boolean] @since 1.1.0

# File lib/cinch/mask.rb, line 29
def eql?(other)
  other.is_a?(self.class) && self == other
end
hash() click to toggle source

@return [Fixnum]

# File lib/cinch/mask.rb, line 34
def hash
  @mask.hash
end
match(target) click to toggle source

@param [Mask, String, mask] target @return [Boolean] @version 1.1.2

# File lib/cinch/mask.rb, line 41
def match(target)
  return self.class.from(target).mask =~ @regexp

  # TODO support CIDR (freenode)
end
Also aliased as: =~
to_s() click to toggle source

@return [String]

# File lib/cinch/mask.rb, line 49
def to_s
  @mask.dup
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.