@api private
# File lib/cinch/pattern.rb, line 27 def initialize(prefix, pattern, suffix) @prefix, @pattern, @suffix = prefix, pattern, suffix end
@param [String, Regexp, NilClass, Proc, to_s] obj The object to
convert to a regexp
@return [Regexp, nil]
# File lib/cinch/pattern.rb, line 7 def self.obj_to_r(obj) case obj when Regexp, NilClass return obj else return Regexp.new(Regexp.escape(obj.to_s)) end end
# File lib/cinch/pattern.rb, line 31 def to_r(msg = nil) prefix = Pattern.obj_to_r(Pattern.resolve_proc(@prefix, msg)) suffix = Pattern.obj_to_r(Pattern.resolve_proc(@suffix, msg)) pattern = Pattern.resolve_proc(@pattern, msg) case pattern when Regexp, NilClass /#{prefix}#{pattern}#{suffix}/ else /^#{prefix}#{Pattern.obj_to_r(pattern)}#{suffix}$/ end end
Generated with the Darkfish Rdoc Generator 2.