Class: Aerospike::StringValue

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

Overview

value string.

Constant Summary

Constants inherited from Value

Value::INTEGER_RANGE

Instance Method Summary collapse

Methods inherited from Value

of

Constructor Details

#initialize(val) ⇒ StringValue

:nodoc:



228
229
230
231
# File 'lib/aerospike/value/value.rb', line 228

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

Instance Method Details

#estimate_sizeObject



233
234
235
# File 'lib/aerospike/value/value.rb', line 233

def estimate_size
  @value.bytesize
end

#getObject



250
251
252
# File 'lib/aerospike/value/value.rb', line 250

def get
  @value
end

#pack(packer) ⇒ Object



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

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

#to_bytesObject



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

def to_bytes
  @value
end

#to_sObject



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

def to_s
  @value
end

#to_symObject



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

def to_sym
  @value.to_sym
end

#typeObject



246
247
248
# File 'lib/aerospike/value/value.rb', line 246

def type
  Aerospike::ParticleType::STRING
end

#write(buffer, offset) ⇒ Object



237
238
239
240
# File 'lib/aerospike/value/value.rb', line 237

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