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.



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

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.



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

def item
  @item
end

#shrinkabilityObject (readonly)

The amount by which the glue could be shrunk.



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

def shrinkability
  @shrinkability
end

#stretchabilityObject (readonly)

The amount by which the glue could be stretched.



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

def stretchability
  @stretchability
end

Instance Method Details

#inspectObject

:nodoc:



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

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

#typeObject

Returns :glue.



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

def type
  :glue
end

#widthObject

The width of the item.



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

def width
  @item.width
end