diff --git a/lib/uplot/command.rb b/lib/uplot/command.rb index 415d818..53743ea 100644 --- a/lib/uplot/command.rb +++ b/lib/uplot/command.rb @@ -205,3 +205,14 @@ module Uplot end end end + +# backports +# https://github.com/marcandre/backports/blob/master/lib/backports/2.7.0/enumerable/tally.rb +unless Enumerable.method_defined? :tally + module Enumerable + def tally + # NB: By spec, tally should return default-less hash + each_with_object(Hash.new(0)) { |item, res| res[item] += 1 }.tap { |h| h.default = nil } + end + end +end