Sha256: 0bd95409cea5cd2ee3c7cfdaafea1ac9c05c814832e7161ad57edfca9f66fd24

Contents?: true

Size: 339 Bytes

Versions: 4

Compression:

Stored size: 339 Bytes

Contents

require 'json'

class Statistic
  def load(data)
    @data = JSON.load data
  end

  def gem_infos
    @data.reduce([]) do |result, gem_info|
      result << [ gem_info['name'], gem_info['downloads']]
    end.sort! { |a,b| a[1] <=> b[1] }.reverse
  end

  def max_gem_name_size
    gem_infos.map { |info| info[0].size }.sort[-1]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rg_stats-1.1.1 lib/rg_stats/statistic.rb
rg_stats-1.1.0 lib/rg_stats/statistic.rb
rg_stats-1.0.2 lib/rg_stats/statistic.rb
rg_stats-1.0.1 lib/rg_stats/statistic.rb