Class: Pgvector::HalfVector
- Inherits:
-
Object
- Object
- Pgvector::HalfVector
- Defined in:
- lib/pgvector/half_vector.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ HalfVector
constructor
A new instance of HalfVector.
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ HalfVector
Returns a new instance of HalfVector.
3 4 5 |
# File 'lib/pgvector/half_vector.rb', line 3 def initialize(data) @data = data.to_a.map(&:to_f) end |
Class Method Details
.from_text(string) ⇒ Object
7 8 9 |
# File 'lib/pgvector/half_vector.rb', line 7 def self.from_text(string) new(string[1..-2].split(",").map(&:to_f)) end |
Instance Method Details
#to_a ⇒ Object
15 16 17 |
# File 'lib/pgvector/half_vector.rb', line 15 def to_a @data end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/pgvector/half_vector.rb', line 11 def to_s "[#{@data.to_a.map(&:to_f).join(",")}]" end |