Class: ShareChecker::Providers::Tweetracker

Inherits:
ShareChecker::Provider show all
Defined in:
lib/share_checker/providers/tweetracker.rb

Instance Attribute Summary

Attributes inherited from ShareChecker::Provider

#name

Instance Method Summary collapse

Methods inherited from ShareChecker::Provider

#check, get, #initialize, #method_missing, #parse_json, #parse_xml

Constructor Details

This class inherits a constructor from ShareChecker::Provider

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ShareChecker::Provider

Instance Method Details

#parse(response) ⇒ Object

Response sample

"tweets":30,
"id":"4e281dcec546612414000004",
"users":26,
"query":"http://www.mcdonaldseurokids2012.com.ua/challenges/1/works/140"

or

<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<track-item>\n  <query>http://www.mcdonaldseurokids2012.com.ua/works/474</query>\n  <tweets type=\"integer\">1</tweets>\n  <users type=\"integer\">1</users>\n  <id>4e8f06abc546611f21000177</id>\n</track-item>\n


18
19
20
21
22
# File 'lib/share_checker/providers/tweetracker.rb', line 18

def parse(response)
  doc = ::Nokogiri::XML(response)
  node = doc.at("users")
  node.nil? ? 0 : node.content.to_i
end

#urlObject



24
25
26
# File 'lib/share_checker/providers/tweetracker.rb', line 24

def url
  "http://tracktweets.aimbulance.com/api/v1/groups/#{group_id}/urls/count.xml?query="
end