Parent

Cinch::Mask

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 [Ban, Mask, User, String] @return [Mask]

# File lib/cinch/mask.rb, line 47
def self.from(target)
  case target
  when User, Ban
    target.mask
  when String
    Mask.new(target)
  when Mask
    target
  else
    raise ArgumentError
  end
end
new(mask) click to toggle source
# File lib/cinch/mask.rb, line 11
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]

# File lib/cinch/mask.rb, line 18
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]

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

@param [Ban, Mask, User, String] target @return [Boolean]

# File lib/cinch/mask.rb, line 33
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 41
def to_s
  @mask.dup
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.