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 glyph boxes contained in this composite box 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 all the glyph 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.
162 163 164 |
# File 'lib/hexapdf/content/processor.rb', line 162 def initialize @boxes = [] end |
Instance Attribute Details
#boxes ⇒ Object (readonly)
The glyph boxes contained in this composite box object.
159 160 161 |
# File 'lib/hexapdf/content/processor.rb', line 159 def boxes @boxes end |
Instance Method Details
#<<(glyph_box) ⇒ Object
Appends the given text glyph box.
167 168 169 170 |
# File 'lib/hexapdf/content/processor.rb', line 167 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.
173 174 175 |
# File 'lib/hexapdf/content/processor.rb', line 173 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.
182 183 184 185 186 |
# File 'lib/hexapdf/content/processor.rb', line 182 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
197 198 199 |
# File 'lib/hexapdf/content/processor.rb', line 197 def lower_left @boxes[0].lower_left end |
#lower_right ⇒ Object
:call-seq:
text.lower_right -> [lrx, lry]
Returns the lower right coordinate
205 206 207 |
# File 'lib/hexapdf/content/processor.rb', line 205 def lower_right @boxes[-1].lower_right end |
#string ⇒ Object
Returns the concatenated text of all the glyph boxes.
189 190 191 |
# File 'lib/hexapdf/content/processor.rb', line 189 def string @boxes.map(&:string).join end |
#upper_left ⇒ Object
:call-seq:
text.upper_left -> [ulx, uly]
Returns the upper left coordinate
213 214 215 |
# File 'lib/hexapdf/content/processor.rb', line 213 def upper_left @boxes[0].upper_left end |
#upper_right ⇒ Object
:call-seq:
text.upper_right -> [urx, ury]
Returns the upper right coordinate.
221 222 223 |
# File 'lib/hexapdf/content/processor.rb', line 221 def upper_right @boxes[-1].upper_right end |