Class: Bstat2google::BucketStats
- Inherits:
-
Object
- Object
- Bstat2google::BucketStats
- Defined in:
- lib/bstat2google.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#id ⇒ Object
Returns the value of attribute id.
-
#kpis ⇒ Object
Returns the value of attribute kpis.
Instance Method Summary collapse
- #flatten_kpis_into_simple_hash(kpi_tuples_array) ⇒ Object
-
#initialize(attrs = {}) ⇒ BucketStats
constructor
A new instance of BucketStats.
Constructor Details
#initialize(attrs = {}) ⇒ BucketStats
Returns a new instance of BucketStats.
14 15 16 17 |
# File 'lib/bstat2google.rb', line 14 def initialize(attrs = {}) attrs[:kpis] = flatten_kpis_into_simple_hash(attrs.delete(:kpis)) attrs.each {|k,v| self.send("#{k}=", v)} end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
13 14 15 |
# File 'lib/bstat2google.rb', line 13 def error @error end |
#id ⇒ Object
Returns the value of attribute id.
13 14 15 |
# File 'lib/bstat2google.rb', line 13 def id @id end |
#kpis ⇒ Object
Returns the value of attribute kpis.
13 14 15 |
# File 'lib/bstat2google.rb', line 13 def kpis @kpis end |
Instance Method Details
#flatten_kpis_into_simple_hash(kpi_tuples_array) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/bstat2google.rb', line 18 def flatten_kpis_into_simple_hash(kpi_tuples_array) results = {} kpi_tuples_array.each do |kpi_tuple| results[kpi_tuple["term"]] = kpi_tuple["count"] end results end |