Class: Arrolio::TextLayout::KnuthPlass::ItemBuilder
- Inherits:
-
Object
- Object
- Arrolio::TextLayout::KnuthPlass::ItemBuilder
- Defined in:
- lib/arrolio/text_layout/knuth_plass/item_builder.rb
Overview
Converts a list of InlineRun values into KnuthPlass::Item sequences (Box, Glue, Penalty). Each word becomes a Box; spaces become Glue; potential break points become Penalty items.
Constant Summary collapse
- HYPHEN_PENALTY =
50.0
Instance Attribute Summary collapse
-
#measurer ⇒ Object
readonly
Returns the value of attribute measurer.
-
#runs ⇒ Object
readonly
Returns the value of attribute runs.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(runs, measurer:) ⇒ ItemBuilder
constructor
A new instance of ItemBuilder.
Constructor Details
#initialize(runs, measurer:) ⇒ ItemBuilder
Returns a new instance of ItemBuilder.
15 16 17 18 |
# File 'lib/arrolio/text_layout/knuth_plass/item_builder.rb', line 15 def initialize(runs, measurer:) @runs = runs @measurer = measurer end |
Instance Attribute Details
#measurer ⇒ Object (readonly)
Returns the value of attribute measurer.
13 14 15 |
# File 'lib/arrolio/text_layout/knuth_plass/item_builder.rb', line 13 def measurer @measurer end |
#runs ⇒ Object (readonly)
Returns the value of attribute runs.
13 14 15 |
# File 'lib/arrolio/text_layout/knuth_plass/item_builder.rb', line 13 def runs @runs end |
Instance Method Details
#build ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/arrolio/text_layout/knuth_plass/item_builder.rb', line 20 def build items = [] @runs.each_with_index do |run, run_idx| build_items_for_run(run, run_idx, items) end items << FINISHED items end |