Sha256: 85f0398aa7632d8af66cd77b2d642488dfcf0ef6b503a071bc1ade45f54ee7c0

Contents?: true

Size: 402 Bytes

Versions: 5

Compression:

Stored size: 402 Bytes

Contents

class PricesUrl

  def initialize(url)
    raise InvalidURL, "You must give an url, ie http://www.ns.nl/api" unless url
    @url = url
  end

  def url (opts = {date: nil, from: "", to: "", date: nil})
    opts[:date] = opts[:date].strftime("%d%m%Y") if opts[:date]
    uri = URI.escape(opts.collect{|k,v| "#{k}=#{v}"}.join('&'))
    "#{@url}?#{uri}"
  end

  class InvalidURL < StandardError
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ns-yapi-0.4.3 lib/model/prices_url.rb
ns-yapi-0.4.2 lib/model/prices_url.rb
ns-yapi-0.4.1 lib/model/prices_url.rb
ns-yapi-0.4.0 lib/model/prices_url.rb
ns-yapi-0.3.0 lib/model/prices_url.rb