This class represents masks, which are primarily used for bans.
@return [String]
@return [String]
@return [String]
@return [String]
@version 1.1.2 @param [String] mask
# File lib/cinch/mask.rb, line 15 def initialize(mask) @mask = mask @nick, @user, @host = mask.match(%r(.+)!(.+)@(.+)/)[1..-1] @regexp = Regexp.new("^" + Regexp.escape(mask).gsub("\\*", ".*").gsub("\\?", ".?") + "$") end
@return [Boolean] @since 1.1.0
# File lib/cinch/mask.rb, line 23 def ==(other) other.respond_to?(:mask) && other.mask == @mask end
@return [Boolean] @since 1.1.0
# File lib/cinch/mask.rb, line 29 def eql?(other) other.is_a?(self.class) && self == other end
@return [Fixnum]
# File lib/cinch/mask.rb, line 34 def hash @mask.hash end
@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
@return [String]
# File lib/cinch/mask.rb, line 49 def to_s @mask.dup end