Class: HexaPDF::Layout::TextLayouter::Glue

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/layout/text_layouter.rb

Overview

Used for layouting. Describes a glue item, i.e. an item describing white space that could potentially be shrunk or stretched.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item, stretchability = item.width / 2, shrinkability = item.width / 3) ⇒ Glue

Creates a new Glue for the item.



119
120
121
122
123
# File 'lib/hexapdf/layout/text_layouter.rb', line 119

def initialize(item, stretchability = item.width / 2, shrinkability = item.width / 3)
  @item = item
  @stretchability = stretchability
  @shrinkability = shrinkability
end

Instance Attribute Details

#itemObject (readonly)

The wrapped item.



110
111
112
# File 'lib/hexapdf/layout/text_layouter.rb', line 110

def item
  @item
end

#shrinkabilityObject (readonly)

The amount by which the glue could be shrunk.



116
117
118
# File 'lib/hexapdf/layout/text_layouter.rb', line 116

def shrinkability
  @shrinkability
end

#stretchabilityObject (readonly)

The amount by which the glue could be stretched.



113
114
115
# File 'lib/hexapdf/layout/text_layouter.rb', line 113

def stretchability
  @stretchability
end

Instance Method Details

#typeObject

Returns :glue.



131
132
133
# File 'lib/hexapdf/layout/text_layouter.rb', line 131

def type
  :glue
end

#widthObject

The width of the item.



126
127
128
# File 'lib/hexapdf/layout/text_layouter.rb', line 126

def width
  @item.width
end