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.



123
124
125
126
127
# File 'lib/hexapdf/layout/text_layouter.rb', line 123

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.



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

def item
  @item
end

#shrinkabilityObject (readonly)

The amount by which the glue could be shrunk.



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

def shrinkability
  @shrinkability
end

#stretchabilityObject (readonly)

The amount by which the glue could be stretched.



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

def stretchability
  @stretchability
end

Instance Method Details

#inspectObject

:nodoc:



139
140
141
# File 'lib/hexapdf/layout/text_layouter.rb', line 139

def inspect #:nodoc:
  "Glue[#{@item.inspect}]"
end

#typeObject

Returns :glue.



135
136
137
# File 'lib/hexapdf/layout/text_layouter.rb', line 135

def type
  :glue
end

#widthObject

The width of the item.



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

def width
  @item.width
end