Sha256: 6bd0c74ae4f5b2b08055fcf6df44ed3f2da2ab50a04f4145db1b749a396c024b
Contents?: true
Size: 503 Bytes
Versions: 2
Compression:
Stored size: 503 Bytes
Contents
require_relative './node' module UrlRegexp class Scheme < Node def initialize @schemes = Set.new end def append(scheme) @schemes << scheme end def to_regexp_s schemes = @schemes.map { |s| Regexp.quote(s) } s = if schemes == %w(http https) "https?://" elsif 1 < @schemes.size "(#{schemes.join('|')})://" elsif 1 == @schemes.size "#{schemes.to_a.first.to_s}://" else "" end s end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
url_regexp-0.1.1 | lib/url_regexp/scheme.rb |
url_regexp-0.1.0 | lib/url_regexp/scheme.rb |