Method: Placemaker::Client#fetch!

Defined in:
lib/placemaker/client.rb

#fetch!Object

Fetches the place information for input parameters from the Yahoo Placemaker service



21
22
23
24
25
26
27
28
29
30
# File 'lib/placemaker/client.rb', line 21

def fetch!
  fields = POST_FIELDS.reject{|f| @options[f].nil? }.map do |f|
    # Change ruby-form fields to url type, e.g., document_content => documentContent
    cgi_param = f.to_s.gsub(/\_(.)/) {|s| s.upcase}.gsub('_', '').sub(/url/i, 'URL')
    Curl::PostField.content(cgi_param, @options[f])
  end

  res         = Curl::Easy.http_post('http://wherein.yahooapis.com/v1/document', *fields)
  @xml_parser = Placemaker::XmlParser.new(res.body_str)
end