Sha256: 9b33853e16f6d91e28e79ce373ac1a0edba144b6de6eb6153bc43c1456115e4a
Contents?: true
Size: 392 Bytes
Versions: 2
Compression:
Stored size: 392 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: ""}) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ns-yapi-0.5.0 | lib/model/prices_url.rb |
ns-yapi-0.4.4 | lib/model/prices_url.rb |