Class: Clef::Layout::LineBreaker

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/layout/line_breaker.rb

Instance Method Summary collapse

Instance Method Details

#break_into_lines(columns, line_width) ⇒ Array<Array<Hash>>

Parameters:

  • columns (Array<Hash>)
  • line_width (Float)

Returns:

  • (Array<Array<Hash>>)


9
10
11
12
13
# File 'lib/clef/layout/line_breaker.rb', line 9

def break_into_lines(columns, line_width)
  costs, breaks = initialize_dp(columns.length)
  1.upto(columns.length) { |idx| update_dp_for_index(columns, line_width, idx, costs, breaks) }
  build_lines(columns, breaks)
end