Class: Histogram
Overview
A histogram in this sense is an array of [value, frequency] pairs
Instance Method Summary collapse
-
#flatten ⇒ Object
Histogram.new([, [2,2], [3,5]).flatten => [1, 2,2, 3,3,3,3,3].
Methods inherited from Array
#after, #average, #before, #classify, #delete_if!, #expand_ranges, #extract_options!, #group_by, #ljust_columns, #ljust_columns!, #ljust_rows, #ljust_rows!, #mean, #rjust_columns, #rjust_columns!, #rjust_rows, #rjust_rows!, #select_if!, #select_if_with_index!, #shell_escape, #sum, #to_a_recursive, #to_query_string, #to_range_list
Instance Method Details
#flatten ⇒ Object
Histogram.new([, [2,2], [3,5]).flatten
> [1, 2,2, 3,3,3,3,3]
15 16 17 18 19 20 21 |
# File 'lib/quality_extensions/histogram.rb', line 15 def flatten array = [] each do |value, frequency| array.concat [value]*frequency end array end |