Class: Kreuzberg::Result::DocumentAnnotation
- Inherits:
-
Object
- Object
- Kreuzberg::Result::DocumentAnnotation
- Defined in:
- lib/kreuzberg/document_structure.rb
Overview
Annotation for a document node.
Represents inline text annotations (formatting, links) with byte-range references into the node’s text content.
Instance Attribute Summary collapse
-
#annotation_type ⇒ Object
readonly
Returns the value of attribute annotation_type.
-
#end_offset ⇒ Object
readonly
Returns the value of attribute end_offset.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(hash) ⇒ DocumentAnnotation
constructor
A new instance of DocumentAnnotation.
-
#to_h ⇒ Hash
Convert to hash.
Constructor Details
#initialize(hash) ⇒ DocumentAnnotation
Returns a new instance of DocumentAnnotation.
166 167 168 169 170 |
# File 'lib/kreuzberg/document_structure.rb', line 166 def initialize(hash) @start = (hash['start'] || hash[:start] || 0).to_i @end_offset = (hash['end'] || hash[:end] || 0).to_i parse_kind(hash['kind'] || hash[:kind] || {}) end |
Instance Attribute Details
#annotation_type ⇒ Object (readonly)
Returns the value of attribute annotation_type.
164 165 166 |
# File 'lib/kreuzberg/document_structure.rb', line 164 def annotation_type @annotation_type end |
#end_offset ⇒ Object (readonly)
Returns the value of attribute end_offset.
164 165 166 |
# File 'lib/kreuzberg/document_structure.rb', line 164 def end_offset @end_offset end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
164 165 166 |
# File 'lib/kreuzberg/document_structure.rb', line 164 def start @start end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
164 165 166 |
# File 'lib/kreuzberg/document_structure.rb', line 164 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
164 165 166 |
# File 'lib/kreuzberg/document_structure.rb', line 164 def url @url end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/kreuzberg/document_structure.rb', line 176 def to_h kind_hash = { annotation_type: @annotation_type } url = @url kind_hash[:url] = url if url title = @title kind_hash[:title] = title if title { start: @start, end: @end_offset, kind: kind_hash } end |