Class: Tabula::Line
- Inherits:
-
ZoneEntity
- Object
- Tabula.javajava.awtjava.awt.geomjava.awt.geom.Rectangle2Djava.awt.geom.Rectangle2D::Float
- ZoneEntity
- Tabula::Line
- Defined in:
- lib/tabula/entities/line.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#text_elements ⇒ Object
Returns the value of attribute text_elements.
Attributes inherited from ZoneEntity
Instance Method Summary collapse
- #<<(t) ⇒ Object
-
#==(other) ⇒ Object
used for testing, ignores text element stuff besides stripped text.
-
#initialize(index = nil) ⇒ Line
constructor
A new instance of Line.
Methods inherited from ZoneEntity
#<=>, #inspect, #merge!, #points, #tlbr, #to_json
Constructor Details
#initialize(index = nil) ⇒ Line
Returns a new instance of Line.
6 7 8 9 |
# File 'lib/tabula/entities/line.rb', line 6 def initialize(index=nil) @text_elements = [] @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
4 5 6 |
# File 'lib/tabula/entities/line.rb', line 4 def index @index end |
#text_elements ⇒ Object
Returns the value of attribute text_elements.
3 4 5 |
# File 'lib/tabula/entities/line.rb', line 3 def text_elements @text_elements end |
Instance Method Details
#<<(t) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tabula/entities/line.rb', line 11 def <<(t) if @text_elements.size == 0 @text_elements << t self.top = t.top self.left = t.left self.width = t.width self.height = t.height else if in_same_column = @text_elements.find { |te| te.horizontally_overlaps?(t) } in_same_column.merge!(t) else self.text_elements << t self.merge!(t) end end end |
#==(other) ⇒ Object
used for testing, ignores text element stuff besides stripped text.
29 30 31 32 33 34 35 36 37 |
# File 'lib/tabula/entities/line.rb', line 29 def ==(other) return false if other.nil? self.text_elements = self.text_elements.rpad(TextElement::EMPTY, other.text_elements.size) other.text_elements = other.text_elements.rpad(TextElement::EMPTY, self.text_elements.size) self.text_elements.zip(other.text_elements).inject(true) do |memo, my_yours| my, yours = my_yours memo && my == yours end end |