Class: Arrolio::TextLayout::KnuthPlass::Item

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

Overview

Base class for items in the Knuth-Plass line-breaking model. Every item has a width. Box and Glue are "content"; Penalty is a potential break point.

Direct Known Subclasses

Box, Glue, Penalty

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width:) ⇒ Item

Returns a new instance of Item.



12
13
14
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 12

def initialize(width:)
  @width = width.to_f
end

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width.



10
11
12
# File 'lib/arrolio/text_layout/knuth_plass/item.rb', line 10

def width
  @width
end

Instance Method Details

#box?Boolean

Returns:

  • (Boolean)


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

def box? = false

#glue?Boolean

Returns:

  • (Boolean)


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

def glue? = false

#penalty?Boolean

Returns:

  • (Boolean)


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

def penalty? = false