Created
August 2, 2008 16:30
-
-
Save ELLIOTTCABLE/3748 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Arrays all currently kown bars, returning a two-dimensional array of | |
# lines and bars on lines, sorting the bars as defined by #<=>, and | |
# splitting the bars into groups of as many as can fit within max_width. | |
def self.array max_width | |
@@bars.sort! | |
@@bars.each {|b| b.reindex! } | |
total = 0 | |
arr = [[]] | |
@@bars.each do |bar| | |
arr << [] if (total + bar.width) > max_width | |
arr.last << bar | |
total += bar.width | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment