Class: Kreuzberg::Result::DocumentBoundingBox

Inherits:
Object
  • Object
show all
Defined in:
lib/kreuzberg/document_structure.rb

Overview

Bounding box for document node positioning.

Represents rectangular coordinates for a node within the document.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ DocumentBoundingBox

Returns a new instance of DocumentBoundingBox.



131
132
133
134
135
136
# File 'lib/kreuzberg/document_structure.rb', line 131

def initialize(hash)
  @x0 = extract_float(hash, 'x0')
  @y0 = extract_float(hash, 'y0')
  @x1 = extract_float(hash, 'x1')
  @y1 = extract_float(hash, 'y1')
end

Instance Attribute Details

#x0Object (readonly)

Returns the value of attribute x0.



129
130
131
# File 'lib/kreuzberg/document_structure.rb', line 129

def x0
  @x0
end

#x1Object (readonly)

Returns the value of attribute x1.



129
130
131
# File 'lib/kreuzberg/document_structure.rb', line 129

def x1
  @x1
end

#y0Object (readonly)

Returns the value of attribute y0.



129
130
131
# File 'lib/kreuzberg/document_structure.rb', line 129

def y0
  @y0
end

#y1Object (readonly)

Returns the value of attribute y1.



129
130
131
# File 'lib/kreuzberg/document_structure.rb', line 129

def y1
  @y1
end

Instance Method Details

#to_hHash

Convert to hash

Returns:

  • (Hash)

    Hash representation



142
143
144
145
146
147
148
149
# File 'lib/kreuzberg/document_structure.rb', line 142

def to_h
  {
    x0: @x0,
    y0: @y0,
    x1: @x1,
    y1: @y1
  }.compact
end