Sha256: b19181fc8a6675258f65983d4e480cb0da9b0757f23fbc5e00ea13c70b83c5c6

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require 'rubygems'
require 'hpricot'

module Gattica
  
  # Represents an account that an authenticated user has access to
  
  class Account
    
    include Convertible
    
    attr_reader :id, :updated, :title, :table_id, :account_id, :account_name,
                :profile_id, :web_property_id, :goals
  
    def initialize(xml)
      @id = xml.at(:id).inner_html
      @updated = DateTime.parse(xml.at(:updated).inner_html)
      @title = xml.at(:title).inner_html
      @table_id = xml.at('dxp:tableid').inner_html
      @account_id = xml.at("dxp:property[@name='ga:accountId']").attributes['value'].to_i
      @account_name = xml.at("dxp:property[@name='ga:accountName']").attributes['value']
      @profile_id = xml.at("dxp:property[@name='ga:profileId']").attributes['value'].to_i
      @web_property_id = xml.at("dxp:property[@name='ga:webPropertyId']").attributes['value']
      @goals = xml.search('ga:goal').collect do |goal| {
        :active => goal.attributes['active'],
        :name => goal.attributes['name'],
        :number => goal.attributes['number'].to_i,
        :value => goal.attributes['value'].to_f,
      }
      end
    end
    
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
songphi-gattica-0.5.3 lib/gattica/account.rb
betapond-gattica-0.5.2 lib/gattica/account.rb
betapond-gattica-0.5.1 lib/gattica/account.rb