lib/to_regexp.rb in to_regexp-0.1.2 vs lib/to_regexp.rb in to_regexp-0.2.0

- old
+ new

@@ -33,10 +33,12 @@ # @see to_regexp def as_regexp(options = {}) unless options.is_a?(::Hash) raise ::ArgumentError, "[to_regexp] Options must be a Hash" end - str = self.strip + str = self + + return if options[:detect] and str == '' if options[:literal] or (options[:detect] and REGEXP_DELIMITERS.none? { |k, v| str.start_with?(k) and str.end_with?(v) }) content = ::Regexp.escape str elsif delim_set = REGEXP_DELIMITERS.detect { |k, v| str.start_with?(k) } delim_start, delim_end = delim_set.map { |delim| ::Regexp.escape delim }