Class: Bstat2google::Source
- Inherits:
-
Object
- Object
- Bstat2google::Source
- Defined in:
- lib/bstat2google.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#bucket_ids ⇒ Object
Returns the value of attribute bucket_ids.
-
#requester ⇒ Object
Returns the value of attribute requester.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(attrs = {}) ⇒ Source
constructor
A new instance of Source.
Constructor Details
#initialize(attrs = {}) ⇒ Source
Returns a new instance of Source.
40 41 42 43 |
# File 'lib/bstat2google.rb', line 40 def initialize(attrs = {}) attrs.each {|k,v| self.send("#{k}=", v)} @requester = BucketStatsRequest unless requester end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
39 40 41 |
# File 'lib/bstat2google.rb', line 39 def api @api end |
#bucket_ids ⇒ Object
Returns the value of attribute bucket_ids.
39 40 41 |
# File 'lib/bstat2google.rb', line 39 def bucket_ids @bucket_ids end |
#requester ⇒ Object
Returns the value of attribute requester.
39 40 41 |
# File 'lib/bstat2google.rb', line 39 def requester @requester end |
Instance Method Details
#each ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bstat2google.rb', line 45 def each if block_given? Array(bucket_ids).each do |bucket_id| req = requester.new api: api, id: bucket_id response = req.get if response.successful? yield(BucketStats.new id: bucket_id, kpis: response.payload["bucket_stats"]) else yield(BucketStats.new id: bucket_id, error: response.payload) end end end end |