Sha256: 4c745af61a3c750ba08408c24eadbed0e1d317cc6f63b02ba1aaaa0992613695

Contents?: true

Size: 581 Bytes

Versions: 8

Compression:

Stored size: 581 Bytes

Contents

require 'addressable/uri'

module Barometer
  module Utils
    class Address
      def initialize(url, query={})
        @address = Addressable::URI.parse(url)
        add(query) unless query.blank?
      end

      def query
        address.query_values
      end

      def url
        address.omit(:query).to_s
      end

      def add(addition)
        current_values = address.query_values || {}
        address.query_values = current_values.merge(addition)
      end

      def to_s
        address.to_s
      end

      private

      attr_reader :address
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
barometer-0.9.7 lib/barometer/utils/address.rb
barometer-0.9.6 lib/barometer/utils/address.rb
barometer-0.9.5 lib/barometer/utils/address.rb
barometer-0.9.4 lib/barometer/utils/address.rb
barometer-0.9.3 lib/barometer/utils/address.rb
barometer-0.9.2 lib/barometer/utils/address.rb
barometer-0.9.1 lib/barometer/utils/address.rb
barometer-0.9.0 lib/barometer/utils/address.rb