Sha256: ef99201b8ffdda66513b7f239f60755e6e0ed2d55cd0a24a182958f54937635e

Contents?: true

Size: 565 Bytes

Versions: 2

Compression:

Stored size: 565 Bytes

Contents

%w(scheme host path query).each do |m|
  require_relative "./#{m}"
end

module UrlRegexp
  class Root < Node
    def initialize
      @scheme = Scheme.new
      @host = Host.new
      @path = Path.new
      @query = Query.new
    end

    def append(url)
      url = URI(url) unless url.is_a?(URI)
      @path.append(url.path)
      @scheme.append(url.scheme)
      @host.append(url.host)
      @query.append(url.query)
    end

    def to_regexp_s
      "^#{@scheme.to_regexp_s}#{@host.to_regexp_s}#{@path.to_regexp_s}#{@query.to_regexp_s}(#|$)"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
url_regexp-0.1.1 lib/url_regexp/root.rb
url_regexp-0.1.0 lib/url_regexp/root.rb