Module: Pygmalion::ClassMethods

Defined in:
lib/pygmalion.rb

Instance Method Summary collapse

Instance Method Details

#pygments_query(parameters = {}, code = nil, chunkid = nil) ⇒ Object

build query string for pygments.com



28
29
30
31
32
33
34
35
# File 'lib/pygmalion.rb', line 28

def pygments_query(parameters = {}, code = nil, chunkid = nil)
  parameters[:code] = code
  parameters[:chunkid] = chunkid if chunkid
  parameters = parameters.collect { |k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
  query = [ chunkid ? PYGMALION_PUSH_PATH : PYGMALION_JSON_PATH ]
  query << parameters unless parameters.empty?
  query.join('?')
end