Sha256: e069f7f65cd1f439b61e1f7a15d1ac97e512857ad9bcb30d937a9fad0af630d9

Contents?: true

Size: 563 Bytes

Versions: 3

Compression:

Stored size: 563 Bytes

Contents

# frozen_string_literal: true

module SiteMaps::Builder
  class Link
    attr_reader :uri

    def initialize(base_url, path, params = {})
      @uri = base_url.is_a?(::URI) ? base_url.dup : ::URI.parse(base_url)
      @uri.user, @uri.query = nil
      @uri.path = path
      @uri.query = Rack::Utils.unescape(Rack::Utils.build_nested_query(params)) if params.is_a?(Hash) && params.any?
    end

    def to_s
      @uri.to_s
    end

    def eql?(other)
      to_s == other.to_s
    end
    alias_method :==, :eql?

    def hash
      to_s.hash
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
site_maps-0.0.1.beta3 lib/site_maps/builder/link.rb
site_maps-0.0.1.beta2 lib/site_maps/builder/link.rb
site_maps-0.0.1.beta1 lib/site_maps/builder/link.rb