Class: Pgvector::HalfVector

Inherits:
Object
  • Object
show all
Defined in:
lib/pgvector/half_vector.rb

Class Method Summary collapse

Instance Method Summary collapse

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_aObject



15
16
17
# File 'lib/pgvector/half_vector.rb', line 15

def to_a
  @data
end

#to_sObject



11
12
13
# File 'lib/pgvector/half_vector.rb', line 11

def to_s
  "[#{@data.to_a.map(&:to_f).join(",")}]"
end