Class: Garb::Profile
- Inherits:
-
Object
- Object
- Garb::Profile
- Includes:
- ProfileReports
- Defined in:
- lib/garb/profile.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#account_name ⇒ Object
readonly
Returns the value of attribute account_name.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#table_id ⇒ Object
readonly
Returns the value of attribute table_id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#web_property_id ⇒ Object
readonly
Returns the value of attribute web_property_id.
Class Method Summary collapse
- .all(session = Session) ⇒ Object
- .first(id, session = Session) ⇒ Object
- .parse(response_body) ⇒ Object
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(entry, session) ⇒ Profile
constructor
A new instance of Profile.
Methods included from ProfileReports
Constructor Details
#initialize(entry, session) ⇒ Profile
Returns a new instance of Profile.
8 9 10 11 12 13 14 15 16 |
# File 'lib/garb/profile.rb', line 8 def initialize(entry, session) @session = session @title = entry['title'] @table_id = entry['dxp:tableId'] entry['dxp:property'].each do |p| instance_variable_set :"@#{Garb.from_ga(p['name'])}", p['value'] end end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
6 7 8 |
# File 'lib/garb/profile.rb', line 6 def account_id @account_id end |
#account_name ⇒ Object (readonly)
Returns the value of attribute account_name.
6 7 8 |
# File 'lib/garb/profile.rb', line 6 def account_name @account_name end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
6 7 8 |
# File 'lib/garb/profile.rb', line 6 def session @session end |
#table_id ⇒ Object (readonly)
Returns the value of attribute table_id.
6 7 8 |
# File 'lib/garb/profile.rb', line 6 def table_id @table_id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/garb/profile.rb', line 6 def title @title end |
#web_property_id ⇒ Object (readonly)
Returns the value of attribute web_property_id.
6 7 8 |
# File 'lib/garb/profile.rb', line 6 def web_property_id @web_property_id end |
Class Method Details
.all(session = Session) ⇒ Object
22 23 24 25 26 |
# File 'lib/garb/profile.rb', line 22 def self.all(session = Session) url = "https://www.google.com/analytics/feeds/accounts/default" response = DataRequest.new(session, url).send_request parse(response.body).map {|entry| new(entry, session)} end |
.first(id, session = Session) ⇒ Object
28 29 30 |
# File 'lib/garb/profile.rb', line 28 def self.first(id, session = Session) all(session).detect {|profile| profile.id == id || profile.web_property_id == id } end |
.parse(response_body) ⇒ Object
32 33 34 35 |
# File 'lib/garb/profile.rb', line 32 def self.parse(response_body) entry_hash = Crack::XML.parse(response_body) entry_hash ? [entry_hash['feed']['entry']].flatten : [] end |
Instance Method Details
#id ⇒ Object
18 19 20 |
# File 'lib/garb/profile.rb', line 18 def id Garb.from_ga(@table_id) end |