Class: Statwhore::Google::Analytics::Account
- Inherits:
-
Google::Base
- Object
- Google::Base
- Statwhore::Google::Analytics::Account
- Defined in:
- lib/statwhore/google/analytics/account.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
Returns the value of attribute account_id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Account
constructor
A new instance of Account.
- #profiles(force = false) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Account
Returns a new instance of Account.
16 17 18 19 |
# File 'lib/statwhore/google/analytics/account.rb', line 16 def initialize(attrs) @name = attrs[:name] @account_id = attrs[:account_id] end |
Instance Attribute Details
#account_id ⇒ Object
Returns the value of attribute account_id.
14 15 16 |
# File 'lib/statwhore/google/analytics/account.rb', line 14 def account_id @account_id end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/statwhore/google/analytics/account.rb', line 14 def name @name end |
Class Method Details
.find_all ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/statwhore/google/analytics/account.rb', line 5 def self.find_all doc = Hpricot::XML(get('https://www.google.com:443/analytics/home/')) (doc/'select[@name=account_list] option').inject([]) do |accounts, option| account_id = option['value'].to_i accounts << new(:account_id => account_id, :name => option.inner_html) if account_id > 0 accounts end end |
Instance Method Details
#profiles(force = false) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/statwhore/google/analytics/account.rb', line 21 def profiles(force=false) if force || @profiles.nil? @profiles = Profile.find_all(account_id) end @profiles end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/statwhore/google/analytics/account.rb', line 28 def to_s "#{name} (#{account_id})" end |