Jeevan Dongre
Jeevan Dongre

Reputation: 4649

How to get particular data from the Openstruct

I am using garb gem to fetch the data from the google analytics and I getting the data in Openstruct format and I am struggling to parse it and get the desired values out.

#<OpenStruct visits="142640", percent_new_visits="100.0", visitor_type="New Visitor">

I googled but did not find anything relevant to this. I am newbie to ruby on rails ENV.

Kindly help me out

Upvotes: 0

Views: 1137

Answers (1)

shingara
shingara

Reputation: 46914

You just call method on args like

object.visits
object.percent_new_visits
object.visitor_type

See the document about OpenStruct on Ruby doc http://ruby-doc.org/stdlib-1.9.3/libdoc/ostruct/rdoc/index.html

Upvotes: 3

Related Questions