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:



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

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

Instance Method Details

#estimate_sizeObject



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

def estimate_size
  @value.bytesize
end

#getObject



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

def get
  @value
end

#pack(packer) ⇒ Object



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

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

#to_bytesObject



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

def to_bytes
  @value
end

#to_sObject



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

def to_s
  @value
end

#to_symObject



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

def to_sym
  @value.to_sym
end

#typeObject



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

def type
  Aerospike::ParticleType::STRING
end

#write(buffer, offset) ⇒ Object



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

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