I am playing with the Garb gem for ruby but I’m having trouble accessing the results.
Here is my code.
Garb::Session.login('user@demo.com', 'password')
profile = Garb::Management::Profile.all.detect {|profile| profile.web_property_id == 'UA-XXXXX-X'}
@ga = profile.stats(:start_date => (Date.today - 1), :end_date => Date.today)
And if I use debug on the view I can see the results but whatever I try I cant access the results.
Here is the debug result
--- !ruby/object:Garb::ResultSet
results:
- !ruby/object:OpenStruct
table:
:exits: "7820"
:pageviews: "24171"
sampled: false
total_results: 1
ie
- @ga.results.table.exits
- @ga.exits
- @ga.table.exits
I have tried making it to an array as well with no luck.
Have you used this gem before? If so how do I access those results.
The
Garb::ResultSetis an enumerator, so you can use any of the enumerator methods on it (each,map, etc.). The individual results areOpenStructs, so you can access them directly.