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, validate_hash_key

Constructor Details

#initialize(val) ⇒ StringValue

:nodoc:



243
244
245
246
# File 'lib/aerospike/value/value.rb', line 243

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

Instance Method Details

#estimate_sizeObject



248
249
250
# File 'lib/aerospike/value/value.rb', line 248

def estimate_size
  @value.bytesize
end

#getObject



265
266
267
# File 'lib/aerospike/value/value.rb', line 265

def get
  @value
end

#pack(packer) ⇒ Object



257
258
259
# File 'lib/aerospike/value/value.rb', line 257

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

#to_bytesObject



269
270
271
# File 'lib/aerospike/value/value.rb', line 269

def to_bytes
  @value
end

#to_sObject



273
274
275
# File 'lib/aerospike/value/value.rb', line 273

def to_s
  @value
end

#to_symObject



277
278
279
# File 'lib/aerospike/value/value.rb', line 277

def to_sym
  @value.to_sym
end

#typeObject



261
262
263
# File 'lib/aerospike/value/value.rb', line 261

def type
  Aerospike::ParticleType::STRING
end

#write(buffer, offset) ⇒ Object



252
253
254
255
# File 'lib/aerospike/value/value.rb', line 252

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