Class: Statwhore::Google::Analytics::Account

Inherits:
Google::Base
  • Object
show all
Defined in:
lib/statwhore/google/analytics/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_idObject

Returns the value of attribute account_id.



14
15
16
# File 'lib/statwhore/google/analytics/account.rb', line 14

def 
  @account_id
end

#nameObject

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_allObject



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|
     = option['value'].to_i
    accounts << new(:account_id => , :name => option.inner_html) if  > 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()
  end
  @profiles
end

#to_sObject



28
29
30
# File 'lib/statwhore/google/analytics/account.rb', line 28

def to_s
  "#{name} (#{})"
end