Class: Arrolio::TextLayout::KnuthPlass::Glue

Inherits:
Item
  • Object
show all
Defined in:
lib/arrolio/text_layout/knuth_plass/item.rb

Overview

Glue represents inter-word space. Has a natural width plus stretchability (how much it can grow) and shrinkability (how much it can shrink). At a break point, trailing glue is discarded (doesn't contribute to line width).

Instance Attribute Summary collapse

Attributes inherited from Item

#width

Instance Method Summary collapse

Methods inherited from Item

#box?, #penalty?

Constructor Details

#initialize(width:, stretch:, shrink:, run_index: nil, char_offset: nil) ⇒ Glue

Returns a new instance of Glue.



43
44
45
46
47
48
49
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 43

def initialize(width:, stretch:, shrink:, run_index: nil, char_offset: nil)
  super(width: width)
  @stretch = stretch.to_f
  @shrink = shrink.to_f
  @run_index = run_index
  @char_offset = char_offset
end

Instance Attribute Details

#char_offsetObject (readonly)

Returns the value of attribute char_offset.



41
42
43
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 41

def char_offset
  @char_offset
end

#run_indexObject (readonly)

Returns the value of attribute run_index.



41
42
43
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 41

def run_index
  @run_index
end

#shrinkObject (readonly)

Returns the value of attribute shrink.



41
42
43
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 41

def shrink
  @shrink
end

#stretchObject (readonly)

Returns the value of attribute stretch.



41
42
43
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 41

def stretch
  @stretch
end

Instance Method Details

#glue?Boolean

Returns:

  • (Boolean)


51
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 51

def glue? = true