Class: Kreuzberg::Result::DocumentStructure
- Inherits:
-
Object
- Object
- Kreuzberg::Result::DocumentStructure
- Defined in:
- lib/kreuzberg/document_structure.rb
Overview
Structured document representation.
Provides a hierarchical, tree-based representation of document content using a flat array of nodes with index-based parent/child references.
Instance Attribute Summary collapse
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(hash) ⇒ DocumentStructure
constructor
A new instance of DocumentStructure.
-
#to_h ⇒ Hash
Convert to hash.
Constructor Details
#initialize(hash) ⇒ DocumentStructure
Returns a new instance of DocumentStructure.
20 21 22 |
# File 'lib/kreuzberg/document_structure.rb', line 20 def initialize(hash) @nodes = parse_nodes(hash['nodes'] || hash[:nodes] || []) end |
Instance Attribute Details
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
18 19 20 |
# File 'lib/kreuzberg/document_structure.rb', line 18 def nodes @nodes end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash
28 29 30 |
# File 'lib/kreuzberg/document_structure.rb', line 28 def to_h { nodes: @nodes.map(&:to_h) } end |