Class: Alexa::API::UrlInfo

Inherits:
Base
  • Object
show all
Defined in:
lib/alexa/api/url_info.rb

Constant Summary collapse

DEFAULT_RESPONSE_GROUP =
["adult_content", "contact_info", "keywords", "language", "links_in_count", "owned_domains", "rank", "rank_by_city", "rank_by_country", "related_links", "site_data", "speed", "usage_stats", "categories"]

Instance Attribute Summary

Attributes inherited from Base

#arguments, #response_body

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parsed_body

Methods included from Utils

camelize, safe_retrieve

Constructor Details

This class inherits a constructor from Alexa::API::Base

Instance Method Details

#categoriesObject



84
85
86
# File 'lib/alexa/api/url_info.rb', line 84

def categories
  @categories ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "Related", "Categories", "CategoryData")
end

#data_urlObject



34
35
36
# File 'lib/alexa/api/url_info.rb', line 34

def data_url
  @data_url ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "TrafficData", "DataUrl", "__content__")
end

#fetch(arguments = {}) ⇒ Object

Raises:



8
9
10
11
12
13
14
15
16
# File 'lib/alexa/api/url_info.rb', line 8

def fetch(arguments = {})
  raise ArgumentError, "You must specify url" unless arguments.has_key?(:url)
  @arguments = arguments

  @arguments[:response_group] = Array(arguments.fetch(:response_group, DEFAULT_RESPONSE_GROUP))

  @response_body = Alexa::Connection.new(@credentials).get(params)
  self
end

#keywordsObject



64
65
66
# File 'lib/alexa/api/url_info.rb', line 64

def keywords
  @keywords ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "Keywords", "Keyword")
end

#language_encodingObject



54
55
56
# File 'lib/alexa/api/url_info.rb', line 54

def language_encoding
  @language_encoding ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "Language", "Encoding")
end

#language_localeObject



50
51
52
# File 'lib/alexa/api/url_info.rb', line 50

def language_locale
  @language_locale ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "Language", "Locale")
end


58
59
60
61
62
# File 'lib/alexa/api/url_info.rb', line 58

def links_in_count
  return @links_in_count if defined?(@links_in_count)
  links_in_count = safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "LinksInCount")
  @links_in_count = links_in_count ? links_in_count.to_i : nil
end

#rankObject

Response attributes



20
21
22
23
24
# File 'lib/alexa/api/url_info.rb', line 20

def rank
  return @rank if defined?(@rank)
  rank = safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "TrafficData", "Rank")
  @rank = rank ? rank.to_i : nil
end

#rank_by_cityObject



30
31
32
# File 'lib/alexa/api/url_info.rb', line 30

def rank_by_city
  @rank_by_city ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "TrafficData", "RankByCity", "City")
end

#rank_by_countryObject



26
27
28
# File 'lib/alexa/api/url_info.rb', line 26

def rank_by_country
  @rank_by_country ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "TrafficData", "RankByCountry", "Country")
end


80
81
82
# File 'lib/alexa/api/url_info.rb', line 80

def related_links
  @related_links ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "Related", "RelatedLinks", "RelatedLink")
end

#request_idObject



92
93
94
# File 'lib/alexa/api/url_info.rb', line 92

def request_id
  @request_id ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "OperationRequest", "RequestId")
end

#site_descriptionObject



46
47
48
# File 'lib/alexa/api/url_info.rb', line 46

def site_description
  @site_description ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "SiteData", "Description")
end

#site_titleObject



42
43
44
# File 'lib/alexa/api/url_info.rb', line 42

def site_title
  @site_title ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "SiteData", "Title")
end

#speed_median_load_timeObject



68
69
70
71
72
# File 'lib/alexa/api/url_info.rb', line 68

def speed_median_load_time
  return @speed_median_load_time if defined?(@speed_median_load_time)
  speed_median_load_time = safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "Speed", "MedianLoadTime")
  @speed_median_load_time = speed_median_load_time ? speed_median_load_time.to_i : nil
end

#speed_percentileObject



74
75
76
77
78
# File 'lib/alexa/api/url_info.rb', line 74

def speed_percentile
  return @speed_percentile if defined?(@speed_percentile)
  speed_percentile = safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "ContentData", "Speed", "Percentile")
  @speed_percentile = speed_percentile ? speed_percentile.to_i : nil
end

#status_codeObject



88
89
90
# File 'lib/alexa/api/url_info.rb', line 88

def status_code
  @status_code ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "ResponseStatus", "StatusCode")
end

#usage_statisticsObject



38
39
40
# File 'lib/alexa/api/url_info.rb', line 38

def usage_statistics
  @usage_statistics ||= safe_retrieve(parsed_body, "UrlInfoResponse", "Response", "UrlInfoResult", "Alexa", "TrafficData", "UsageStatistics", "UsageStatistic")
end