Class: SystemMetrics::Collector
- Inherits:
-
Object
- Object
- SystemMetrics::Collector
- Defined in:
- lib/system_metrics/collector.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #collect ⇒ Object
- #collect_event(event) ⇒ Object
-
#initialize(store) ⇒ Collector
constructor
A new instance of Collector.
Constructor Details
#initialize(store) ⇒ Collector
Returns a new instance of Collector.
5 6 7 |
# File 'lib/system_metrics/collector.rb', line 5 def initialize(store) @store = store end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
3 4 5 |
# File 'lib/system_metrics/collector.rb', line 3 def store @store end |
Instance Method Details
#collect ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/system_metrics/collector.rb', line 13 def collect events.clear SystemMetrics.collection_on result = yield SystemMetrics.collection_off store.save events.dup result ensure SystemMetrics.collection_off events.clear end |
#collect_event(event) ⇒ Object
9 10 11 |
# File 'lib/system_metrics/collector.rb', line 9 def collect_event(event) events.push event if SystemMetrics.collecting? end |