Sha256: 35a371fa901868873a4f9e8a0415f9188c94afc66541ec46e99218d3b3d796bb

Contents?: true

Size: 505 Bytes

Versions: 4

Compression:

Stored size: 505 Bytes

Contents

module USaidWat
  module CLI
    class TallyFormatter
      include TTYFormatter

      def format(partition_data)
        out = StringIO.new
        longest_subreddit = partition_data.longest
        subreddits = partition_data.counts
        subreddits.each do |subreddit_count|
          subreddit, tally = subreddit_count
          line = sprintf("%-*s  %3d\n", longest_subreddit, subreddit, tally)
          out.write(line)
        end
        out.rewind
        out.read
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
usaidwat-1.6.1 lib/usaidwat/formatter/count.rb
usaidwat-1.6.0 lib/usaidwat/formatter/count.rb
usaidwat-1.5.1 lib/usaidwat/formatter/count.rb
usaidwat-1.5.0 lib/usaidwat/formatter/count.rb