Class: HexaPDF::Content::Processor::CompositeBox
- Inherits:
-
Object
- Object
- HexaPDF::Content::Processor::CompositeBox
- Defined in:
- lib/hexapdf/content/processor.rb
Overview
Represents a box composed of GlyphBox objects.
The bounding box methods #lower_left, #lower_right, #upper_left, #upper_right are computed by just using the first and last boxes, assuming the boxes are arranged from left to right in a straight line.
Instance Attribute Summary collapse
-
#boxes ⇒ Object
readonly
The text boxes contained in this positioned text object.
Instance Method Summary collapse
-
#<<(glyph_box) ⇒ Object
Appends the given text glyph box.
-
#[](index) ⇒ Object
Returns the glyph box at the given index, or
nil
if the index is out of range. -
#each(&block) ⇒ Object
:call-seq: composite.each {|glyph_box| block} -> composite composite.each -> Enumerator.
-
#initialize ⇒ CompositeBox
constructor
Creates an empty object.
-
#lower_left ⇒ Object
:call-seq: text.lower_left -> [llx, lly].
-
#lower_right ⇒ Object
:call-seq: text.lower_right -> [lrx, lry].
-
#string ⇒ Object
Returns the concatenated text of the boxes.
-
#upper_left ⇒ Object
:call-seq: text.upper_left -> [ulx, uly].
-
#upper_right ⇒ Object
:call-seq: text.upper_right -> [urx, ury].
Constructor Details
#initialize ⇒ CompositeBox
Creates an empty object.
159 160 161 |
# File 'lib/hexapdf/content/processor.rb', line 159 def initialize @boxes = [] end |
Instance Attribute Details
#boxes ⇒ Object (readonly)
The text boxes contained in this positioned text object.
156 157 158 |
# File 'lib/hexapdf/content/processor.rb', line 156 def boxes @boxes end |
Instance Method Details
#<<(glyph_box) ⇒ Object
Appends the given text glyph box.
164 165 166 167 |
# File 'lib/hexapdf/content/processor.rb', line 164 def <<(glyph_box) @boxes << glyph_box self end |
#[](index) ⇒ Object
Returns the glyph box at the given index, or nil
if the index is out of range.
170 171 172 |
# File 'lib/hexapdf/content/processor.rb', line 170 def [](index) @boxes[index] end |
#each(&block) ⇒ Object
:call-seq:
composite.each {|glyph_box| block} -> composite
composite.each -> Enumerator
Iterates over all contained glyph boxes.
179 180 181 182 183 |
# File 'lib/hexapdf/content/processor.rb', line 179 def each(&block) return to_enum(__method__) unless block_given? @boxes.each(&block) self end |
#lower_left ⇒ Object
:call-seq:
text.lower_left -> [llx, lly]
Returns the lower left coordinate
194 195 196 |
# File 'lib/hexapdf/content/processor.rb', line 194 def lower_left @boxes[0].lower_left end |
#lower_right ⇒ Object
:call-seq:
text.lower_right -> [lrx, lry]
Returns the lower right coordinate
202 203 204 |
# File 'lib/hexapdf/content/processor.rb', line 202 def lower_right @boxes[-1].lower_right end |
#string ⇒ Object
Returns the concatenated text of the boxes.
186 187 188 |
# File 'lib/hexapdf/content/processor.rb', line 186 def string @boxes.map(&:string).join('') end |
#upper_left ⇒ Object
:call-seq:
text.upper_left -> [ulx, uly]
Returns the upper left coordinate
210 211 212 |
# File 'lib/hexapdf/content/processor.rb', line 210 def upper_left @boxes[0].upper_left end |
#upper_right ⇒ Object
:call-seq:
text.upper_right -> [urx, ury]
Returns the upper right coordinate.
218 219 220 |
# File 'lib/hexapdf/content/processor.rb', line 218 def upper_right @boxes[-1].upper_right end |