Sha256: 43315818074489be88dd1c8fc0735d7364196e2f7a59078de4e263224ccd0918
Contents?: true
Size: 859 Bytes
Versions: 1
Compression:
Stored size: 859 Bytes
Contents
require 'cgi' require 'rest-client' module Slate class Graph def initialize(options={}) @from = options[:from] @until = options[:until] end def <<(target) @target = target end def url(format=:png) options = url_options.push(["format", format.to_s]) "#{Configuration.instance.endpoint}/render?#{params(options)}" end def download(format=:png) RestClient.get url(format) end private def url_options options = [] options << ["target", @target.to_s] options << ["from", @from] if @from options << ["until", @until] if @until options end def params(options={}) options.map do |param| key = param.first value = param.last "#{CGI.escape(key)}=#{CGI.escape(value)}" end.join("&") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slate-0.0.3 | lib/slate/graph.rb |