Class: Refocus::Samples::Collector
- Inherits:
-
Object
- Object
- Refocus::Samples::Collector
- Defined in:
- lib/refocus/samples/collector.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#samples ⇒ Object
readonly
Returns the value of attribute samples.
Instance Method Summary collapse
- #add(name:, aspect:, value:) ⇒ Object
-
#initialize(http:) ⇒ Collector
constructor
A new instance of Collector.
- #json(response) ⇒ Object
- #submit ⇒ Object
Constructor Details
#initialize(http:) ⇒ Collector
Returns a new instance of Collector.
7 8 9 10 |
# File 'lib/refocus/samples/collector.rb', line 7 def initialize(http:) @http = http @samples = [] end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
5 6 7 |
# File 'lib/refocus/samples/collector.rb', line 5 def http @http end |
#samples ⇒ Object (readonly)
Returns the value of attribute samples.
5 6 7 |
# File 'lib/refocus/samples/collector.rb', line 5 def samples @samples end |
Instance Method Details
#add(name:, aspect:, value:) ⇒ Object
12 13 14 |
# File 'lib/refocus/samples/collector.rb', line 12 def add(name:, aspect:, value:) samples << {name: "#{name}|#{aspect}", value: value.to_s} end |
#json(response) ⇒ Object
22 23 24 |
# File 'lib/refocus/samples/collector.rb', line 22 def json(response) JSON.parse(response.body) end |
#submit ⇒ Object
16 17 18 19 20 |
# File 'lib/refocus/samples/collector.rb', line 16 def submit result = json(http.post("upsert/bulk", body: samples, expects: 200)) samples.clear true end |