Class: Garb::Management::Feed

Inherits:
Object
  • Object
show all
Defined in:
lib/garb/management/feed.rb

Constant Summary collapse

BASE_URL =
"https://www.google.com/analytics/feeds/datasources/ga"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, path) ⇒ Feed

Returns a new instance of Feed.



8
9
10
# File 'lib/garb/management/feed.rb', line 8

def initialize(session, path)
  @request = DataRequest.new(session, BASE_URL+path)
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/garb/management/feed.rb', line 6

def request
  @request
end

Instance Method Details

#entriesObject



16
17
18
19
# File 'lib/garb/management/feed.rb', line 16

def entries
  # possible to have nil entries, yuck
  parsed_response ? [parsed_response['feed']['entry']].flatten.reject {|e| e.nil?} : []
end

#parsed_responseObject



12
13
14
# File 'lib/garb/management/feed.rb', line 12

def parsed_response
  @parsed_response ||= Crack::XML.parse(response.body)
end

#responseObject



21
22
23
# File 'lib/garb/management/feed.rb', line 21

def response
  @response ||= request.send_request
end