Sha256: a72f42296a0a4f9ac3f9689c55f2b5df0487396921a481a9da0f9af83b533894
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.2 | lib/slate/graph.rb |