Class: HexaPDF::Layout::TextBox::Penalty
- Inherits:
-
Object
- Object
- HexaPDF::Layout::TextBox::Penalty
- Defined in:
- lib/hexapdf/layout/text_box.rb
Overview
Used for layouting. Describes a penalty item, i.e. a point where a break is allowed.
If the penalty is greater than or equal to INFINITY, a break is forbidden. If it is smaller than or equal to -INFINITY, a break is mandatory.
If a penalty contains an item and a break occurs at the penalty (taking the width of the penalty/item into account), then the penality item must be the last item of the line.
Constant Summary collapse
- INFINITY =
All numbers greater than this one are deemed infinite.
1000
- MandatoryBreak =
Singleton object describing a Penalty for a mandatory break.
new(-Penalty::INFINITY)
- ProhibitedBreak =
Singleton object describing a Penalty for a prohibited break.
new(Penalty::INFINITY)
- Standard =
Singleton object describing a standard Penalty, e.g. for hyphens.
new(50)
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
The wrapped item.
-
#penalty ⇒ Object
readonly
The penalty for breaking at this point.
-
#width ⇒ Object
readonly
The width assigned to this item.
Instance Method Summary collapse
-
#initialize(penalty, width = 0, item: nil) ⇒ Penalty
constructor
Creates a new Penalty with the given penality.
-
#type ⇒ Object
Returns :penalty.
Constructor Details
#initialize(penalty, width = 0, item: nil) ⇒ Penalty
Creates a new Penalty with the given penality.
140 141 142 143 144 |
# File 'lib/hexapdf/layout/text_box.rb', line 140 def initialize(penalty, width = 0, item: nil) @penalty = penalty @width = width @item = item end |
Instance Attribute Details
#item ⇒ Object (readonly)
The wrapped item.
137 138 139 |
# File 'lib/hexapdf/layout/text_box.rb', line 137 def item @item end |
#penalty ⇒ Object (readonly)
The penalty for breaking at this point.
131 132 133 |
# File 'lib/hexapdf/layout/text_box.rb', line 131 def penalty @penalty end |
#width ⇒ Object (readonly)
The width assigned to this item.
134 135 136 |
# File 'lib/hexapdf/layout/text_box.rb', line 134 def width @width end |
Instance Method Details
#type ⇒ Object
Returns :penalty.
147 148 149 |
# File 'lib/hexapdf/layout/text_box.rb', line 147 def type :penalty end |