Class: PwnalyticsClient::Site
- Inherits:
-
Object
- Object
- PwnalyticsClient::Site
- Defined in:
- lib/pwnalytics_client/site.rb
Overview
Information about a site on a Pwnalytics server.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
PwnalyticsClient connection used for queries.
-
#name ⇒ Object
readonly
User-friendly name for the site.
-
#uid ⇒ Object
readonly
Pwnalytics UID for the site.
Instance Method Summary collapse
-
#events(options = {}) ⇒ Object
Queries the Pwnalytics server for events matching some criteria.
-
#initialize(client, uid, name = 'unknown') ⇒ Site
constructor
New wrapper for a site on a Pwnalytics server.
Constructor Details
#initialize(client, uid, name = 'unknown') ⇒ Site
New wrapper for a site on a Pwnalytics server.
This is called automatically by PwnalyticsClient in #sites and #site.
Args:
client:: the PwnalyticsClient connection to be used for queries
uid:: site's Pwnalytics UID
name:: site's user-friendly name (optional)
16 17 18 19 20 |
# File 'lib/pwnalytics_client/site.rb', line 16 def initialize(client, uid, name = 'unknown') @client = client @uid = uid @name = name end |
Instance Attribute Details
#client ⇒ Object (readonly)
PwnalyticsClient connection used for queries.
23 24 25 |
# File 'lib/pwnalytics_client/site.rb', line 23 def client @client end |
#name ⇒ Object (readonly)
User-friendly name for the site
27 28 29 |
# File 'lib/pwnalytics_client/site.rb', line 27 def name @name end |
#uid ⇒ Object (readonly)
Pwnalytics UID for the site.
25 26 27 |
# File 'lib/pwnalytics_client/site.rb', line 25 def uid @uid end |
Instance Method Details
#events(options = {}) ⇒ Object
Queries the Pwnalytics server for events matching some criteria.
Options supports the following keys:
:names:: only get events whose names are contained in this array
:limit:: return the first events matching the criteria
Events will be resturned in the reverse order of their occurrence.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pwnalytics_client/site.rb', line 36 def events( = {}) request = "/web_properties/#{@uid}/events.json?" request << "limit=#{[:limit] || 'no'}" if [:names] request << [:names]. map { |name| '&names%5B%5D=' + CGI.escape(name.to_s) }.join('') end @client.request(request).map { |data| Event.new self, data } end |