lundi 16 mai 2016

Regarding usage of httparty

I am using httparty module. But some of the things I am not able to understand:

I am calling Coursera.for "python" for invoking (eventhough I am using include HTTParty). I am not 'extending HTTParty' then why new instance of Coursera class is not needed? Please help me understand this. There is code which is working but my understanding is not clear on pp Coursera.for "python"

require 'httparty'

require 'pp'

class Coursera

include HTTParty

base_uri 'http://ift.tt/1OxnZ5U'

default_params fields: "smallIcon,shortDescription",q: "search"

format (:json)

def self.for term get("",query: {query:term})["elements"]

end

end

pp Coursera.for "python"

Aucun commentaire:

Enregistrer un commentaire