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:



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

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

Instance Method Details

#estimate_sizeObject



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

def estimate_size
  @value.bytesize
end

#getObject



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

def get
  @value
end

#pack(packer) ⇒ Object



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

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

#to_bytesObject



281
282
283
# File 'lib/aerospike/value/value.rb', line 281

def to_bytes
  @value
end

#to_sObject



285
286
287
# File 'lib/aerospike/value/value.rb', line 285

def to_s
  @value
end

#to_symObject



289
290
291
# File 'lib/aerospike/value/value.rb', line 289

def to_sym
  @value.to_sym
end

#typeObject



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

def type
  Aerospike::ParticleType::STRING
end

#write(buffer, offset) ⇒ Object



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

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