Sha256: 3754e14ff20f991b4de0d494b57579688b9ed6827ba45f83a8f74153c6e4d175

Contents?: true

Size: 665 Bytes

Versions: 1

Compression:

Stored size: 665 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
      s = '^' +
          @scheme.to_regexp_s +
          @host.to_regexp_s +
          @path.to_regexp_s +
          @query.to_regexp_s +
          '(#|$)'
      s.sub('(\\?.*)?(#|$)', '([?#]|$)')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
url_regexp-0.1.2 lib/url_regexp/root.rb