Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/histo_plot.rb
Instance Method Summary collapse
Instance Method Details
#histo_plot(scale: 1, plot_char: '*', &block) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/histo_plot.rb', line 4 def histo_plot(scale: 1, plot_char: '*', &block) block = block_given? ? block : proc {|n| n} h = (self.group_by &block) max_key = h.keys.map(&:to_s).map(&:length).max h.each{|k,v| puts "#{k.to_s.ljust(max_key)}: #{plot_char * (v.count/scale)}"} nil end |