Class: Unleash::Metrics
- Inherits:
-
Object
- Object
- Unleash::Metrics
- Defined in:
- lib/unleash/metrics.rb
Instance Attribute Summary collapse
-
#features ⇒ Object
Returns the value of attribute features.
Instance Method Summary collapse
- #increment(feature, choice) ⇒ Object
-
#initialize ⇒ Metrics
constructor
A new instance of Metrics.
- #reset ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Metrics
Returns a new instance of Metrics.
6 7 8 |
# File 'lib/unleash/metrics.rb', line 6 def initialize self.features = {} end |
Instance Attribute Details
#features ⇒ Object
Returns the value of attribute features.
4 5 6 |
# File 'lib/unleash/metrics.rb', line 4 def features @features end |
Instance Method Details
#increment(feature, choice) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/unleash/metrics.rb', line 14 def increment(feature, choice) raise "InvalidArgument choice must be :yes or :no" unless [:yes, :no].include? choice self.features[feature] = {yes: 0, no: 0} unless self.features.include? feature self.features[feature][choice] += 1 end |
#reset ⇒ Object
21 22 23 |
# File 'lib/unleash/metrics.rb', line 21 def reset self.features = {} end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/unleash/metrics.rb', line 10 def to_s self.features.to_json end |