Module: PryRemoteEm::Metrics
Overview
Simple metrics system See Sandbox section in Readme for guide
Instance Method Summary collapse
- #add(name, value = 1) ⇒ Object
- #any? ⇒ Boolean
- #get(name) ⇒ Object
- #list ⇒ Object
- #maximum(name, value) ⇒ Object
- #minimum(name, value) ⇒ Object
- #reduce(name, value = 1) ⇒ Object
- #set(name, value) ⇒ Object
Instance Method Details
#add(name, value = 1) ⇒ Object
9 10 11 |
# File 'lib/pry-remote-em/metrics.rb', line 9 def add(name, value = 1) list[name] += value end |
#any? ⇒ Boolean
33 34 35 |
# File 'lib/pry-remote-em/metrics.rb', line 33 def any? list.any? end |
#get(name) ⇒ Object
29 30 31 |
# File 'lib/pry-remote-em/metrics.rb', line 29 def get(name) list[name] end |
#list ⇒ Object
5 6 7 |
# File 'lib/pry-remote-em/metrics.rb', line 5 def list @list ||= Hash.new { |hash, key| hash[key] = 0 } end |
#maximum(name, value) ⇒ Object
17 18 19 |
# File 'lib/pry-remote-em/metrics.rb', line 17 def maximum(name, value) list[name] = value if list[name] < value end |
#minimum(name, value) ⇒ Object
21 22 23 |
# File 'lib/pry-remote-em/metrics.rb', line 21 def minimum(name, value) list[name] = value if list[name] > value end |
#reduce(name, value = 1) ⇒ Object
13 14 15 |
# File 'lib/pry-remote-em/metrics.rb', line 13 def reduce(name, value = 1) add(name, -value) end |
#set(name, value) ⇒ Object
25 26 27 |
# File 'lib/pry-remote-em/metrics.rb', line 25 def set(name, value) list[name] = value end |