Class: Documentrix::Documents::Cache::Records::Record
- Inherits:
-
JSON::GenericObject
- Object
- JSON::GenericObject
- Documentrix::Documents::Cache::Records::Record
- Defined in:
- lib/documentrix/documents/cache/records.rb
Overview
A record class for caching document embeddings and their associated metadata.
This class extends JSON::GenericObject and is used to represent cached document entries in the Documentrix library. It stores text content, embedding vectors, normalization values, source information, and tags associated with each document record. The class provides methods for string representation, tag handling, and equality comparison based on text content.
Instance Method Summary collapse
-
#==(other) ⇒ FalseClass, TrueClass
The == method compares this record with another one by comparing their text fields.
-
#initialize(options = {}) ⇒ Record
constructor
The initialize method sets default values for the text and norm attributes.
-
#tags_set ⇒ Documentrix::Utils::Tags
The tags_set method creates a new Documentrix::Utils::Tags object from the tags and source of this instance.
-
#to_s ⇒ String
(also: #inspect)
The to_s method returns a string representation of the object.
Constructor Details
#initialize(options = {}) ⇒ Record
The initialize method sets default values for the text and norm attributes.
21 22 23 24 25 |
# File 'lib/documentrix/documents/cache/records.rb', line 21 def initialize( = {}) super self.text ||= '' self.norm ||= 0.0 end |
Instance Method Details
#==(other) ⇒ FalseClass, TrueClass
The == method compares this record with another one by comparing their text fields.
52 53 54 |
# File 'lib/documentrix/documents/cache/records.rb', line 52 def ==(other) text == other.text end |
#tags_set ⇒ Documentrix::Utils::Tags
The tags_set method creates a new Documentrix::Utils::Tags object from the tags and source of this instance.
41 42 43 |
# File 'lib/documentrix/documents/cache/records.rb', line 41 def Documentrix::Utils::Tags.new(, source:) end |
#to_s ⇒ String Also known as: inspect
The to_s method returns a string representation of the object.
31 32 33 34 35 |
# File 'lib/documentrix/documents/cache/records.rb', line 31 def to_s = .empty? or = " #{}" "#<#{self.class} #{text.inspect}#{} #{similarity || 'n/a'}>" end |