Class: Ralexa::TopSites
- Inherits:
-
AbstractService
- Object
- AbstractService
- Ralexa::TopSites
- Defined in:
- lib/ralexa/top_sites.rb
Defined Under Namespace
Constant Summary collapse
- PER_PAGE =
100
Instance Method Summary collapse
-
#country(code, limit, params = {}) ⇒ Object
Top sites for the specified two letter country code.
-
#global(limit, params = {}) ⇒ Object
A global list of top sites.
-
#list_countries(params = {}) ⇒ Object
All countries that have Alexa top sites.
Methods inherited from AbstractService
Constructor Details
This class inherits a constructor from Ralexa::AbstractService
Instance Method Details
#country(code, limit, params = {}) ⇒ Object
Top sites for the specified two letter country code.
18 19 20 21 22 23 24 25 26 |
# File 'lib/ralexa/top_sites.rb', line 18 def country(code, limit, params = {}) paginating_collection( limit, PER_PAGE, {"ResponseGroup" => "Country", "CountryCode" => code.to_s.upcase}, params, &top_sites_parser ) end |
#global(limit, params = {}) ⇒ Object
A global list of top sites.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ralexa/top_sites.rb', line 7 def global(limit, params = {}) paginating_collection( limit, PER_PAGE, {"ResponseGroup" => "Country"}, params, &top_sites_parser ) end |
#list_countries(params = {}) ⇒ Object
All countries that have Alexa top sites.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ralexa/top_sites.rb', line 29 def list_countries(params = {}) collection({"ResponseGroup" => "ListCountries"}, params) do |document| path = "//TopSitesResult/Alexa/TopSites/Countries" document.at(path).elements.map do |node| Country.new( node.at("Name").text, node.at("Code").text, node.at("TotalSites").text.to_i, node.at("PageViews").text.to_f * 1_000_000, node.at("Users").text.to_f * 1_000_000, ) end end end |