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
nilif 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.
164 165 166 |
# File 'lib/hexapdf/content/processor.rb', line 164 def initialize @boxes = [] end |
Instance Attribute Details
#boxes ⇒ Object (readonly)
The glyph boxes contained in this composite box object.
161 162 163 |
# File 'lib/hexapdf/content/processor.rb', line 161 def boxes @boxes end |
Instance Method Details
#<<(glyph_box) ⇒ Object
Appends the given text glyph box.
169 170 171 172 |
# File 'lib/hexapdf/content/processor.rb', line 169 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.
175 176 177 |
# File 'lib/hexapdf/content/processor.rb', line 175 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.
184 185 186 187 188 |
# File 'lib/hexapdf/content/processor.rb', line 184 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
199 200 201 |
# File 'lib/hexapdf/content/processor.rb', line 199 def lower_left @boxes[0].lower_left end |
#lower_right ⇒ Object
:call-seq:
text.lower_right -> [lrx, lry]
Returns the lower right coordinate
207 208 209 |
# File 'lib/hexapdf/content/processor.rb', line 207 def lower_right @boxes[-1].lower_right end |
#string ⇒ Object
Returns the concatenated text of all the glyph boxes.
191 192 193 |
# File 'lib/hexapdf/content/processor.rb', line 191 def string @boxes.map(&:string).join end |
#upper_left ⇒ Object
:call-seq:
text.upper_left -> [ulx, uly]
Returns the upper left coordinate
215 216 217 |
# File 'lib/hexapdf/content/processor.rb', line 215 def upper_left @boxes[0].upper_left end |
#upper_right ⇒ Object
:call-seq:
text.upper_right -> [urx, ury]
Returns the upper right coordinate.
223 224 225 |
# File 'lib/hexapdf/content/processor.rb', line 223 def upper_right @boxes[-1].upper_right end |