Sha256: faa789a697ba3b2e12119f5a898f95760768b908093bbd02448d04e204302fb0

Contents?: true

Size: 532 Bytes

Versions: 13

Compression:

Stored size: 532 Bytes

Contents

module Vzaar
  module Request
    class Url < Struct.new(:url, :format, :params)
      include Vzaar::Helper

      def build
        _params = build_params
        blank?(_params) ? base_url : (base_url + "?" + _params)
      end

      private

      def base_url
        @base_url ||= blank?(format) ? url : url + ".#{format.to_s}"
      end

      def build_params
        _params = params ? (params.delete_if {|k,v| v.nil?}) : {}
        URI.escape(_params.collect { |k,v| "#{k}=#{v}" }.join('&'))
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
vzaar-1.6.0 lib/vzaar/request/url.rb
vzaar-1.5.3 lib/vzaar/request/url.rb
vzaar-1.5.2 lib/vzaar/request/url.rb
vzaar-1.5.1 lib/vzaar/request/url.rb
vzaar-1.5.0 lib/vzaar/request/url.rb
vzaar-1.4.4 lib/vzaar/request/url.rb
vzaar-1.4.1 lib/vzaar/request/url.rb
vzaar-1.3.1 lib/vzaar/request/url.rb
vzaar-1.3.0 lib/vzaar/request/url.rb
vzaar-1.2.4 lib/vzaar/request/url.rb
vzaar-1.2.3 lib/vzaar/request/url.rb
vzaar-1.2.2 lib/vzaar/request/url.rb
vzaar-1.0.0 lib/vzaar/request/url.rb