From 6db2372c293ffa2eeaeed58dc101407423c3971d Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 15 Aug 2020 16:02:31 +0900 Subject: [PATCH] Minor style changes --- lib/uplot/command.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/uplot/command.rb b/lib/uplot/command.rb index 0b46a97..a06498b 100644 --- a/lib/uplot/command.rb +++ b/lib/uplot/command.rb @@ -184,12 +184,17 @@ module Uplot end def preprocess_count(data) + # tally was added in Ruby 2.7 if Enumerable.method_defined? :tally data[0].tally - else # https://github.com/marcandre/backports tally + else + # https://github.com/marcandre/backports data[0].each_with_object(Hash.new(0)) { |item, res| res[item] += 1 } .tap { |h| h.default = nil } - end.sort { |a, b| a[1] <=> b[1] }.reverse.transpose + end + .sort { |a, b| a[1] <=> b[1] } + .reverse + .transpose end def barplot(data, headers)