Class: Bstat2google::BucketStats

Inherits:
Object
  • Object
show all
Defined in:
lib/bstat2google.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorObject

Returns the value of attribute error.



13
14
15
# File 'lib/bstat2google.rb', line 13

def error
  @error
end

#idObject

Returns the value of attribute id.



13
14
15
# File 'lib/bstat2google.rb', line 13

def id
  @id
end

#kpisObject

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