Class: BloodContracts::Statistics
- Inherits:
-
Object
- Object
- BloodContracts::Statistics
- Extended by:
- Dry::Initializer
- Defined in:
- lib/blood_contracts/statistics.rb
Instance Method Summary collapse
Instance Method Details
#found_unexpected_behavior? ⇒ Boolean
22 23 24 |
# File 'lib/blood_contracts/statistics.rb', line 22 def found_unexpected_behavior? storage.key?(Storage::UNDEFINED_RULE) end |
#store(rule) ⇒ Object
7 8 9 |
# File 'lib/blood_contracts/statistics.rb', line 7 def store(rule) storage[rule] += 1 end |
#to_h ⇒ Object
11 12 13 |
# File 'lib/blood_contracts/statistics.rb', line 11 def to_h Hash[storage.map { |rule_name, times| [rule_name, rule_stats(times)] }] end |
#to_s ⇒ Object
15 16 17 18 19 20 |
# File 'lib/blood_contracts/statistics.rb', line 15 def to_s to_h.map do |name, occasions| " - '#{name}' happened #{occasions.times} time(s) "\ "(#{(occasions.percent * 100).round(2)}% of the time)" end.join("; \n") end |