Class: Aerospike::StringValue

Inherits:
Value
  • Object
show all
Defined in:
lib/aerospike/value/value.rb

Overview

value string.

Instance Method Summary collapse

Methods inherited from Value

of

Constructor Details

#initialize(val) ⇒ StringValue

:nodoc:



145
146
147
148
# File 'lib/aerospike/value/value.rb', line 145

def initialize(val)
  @value = val || ''
  self
end

Instance Method Details

#estimate_sizeObject



150
151
152
# File 'lib/aerospike/value/value.rb', line 150

def estimate_size
  @value.bytesize
end

#getObject



167
168
169
# File 'lib/aerospike/value/value.rb', line 167

def get
  @value
end

#pack(packer) ⇒ Object



159
160
161
# File 'lib/aerospike/value/value.rb', line 159

def pack(packer)
  packer.write(Aerospike::ParticleType::STRING.chr + @value)
end

#to_bytesObject



171
172
173
# File 'lib/aerospike/value/value.rb', line 171

def to_bytes
  @value
end

#to_sObject



175
176
177
# File 'lib/aerospike/value/value.rb', line 175

def to_s
  @value
end

#to_symObject



179
180
181
# File 'lib/aerospike/value/value.rb', line 179

def to_sym
  @value.to_sym
end

#typeObject



163
164
165
# File 'lib/aerospike/value/value.rb', line 163

def type
  Aerospike::ParticleType::STRING
end

#write(buffer, offset) ⇒ Object



154
155
156
157
# File 'lib/aerospike/value/value.rb', line 154

def write(buffer, offset)
  bytes = @value.encode(Aerospike.encoding).force_encoding(Encoding::BINARY)
  buffer.write_binary(bytes, offset)
end