Class: Aerospike::BytesValue

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

Overview

Byte array value.

Instance Method Summary collapse

Methods inherited from Value

of, validate_hash_key

Constructor Details

#initialize(value) ⇒ BytesValue

:nodoc:



201
202
203
204
205
206
# File 'lib/aerospike/value/value.rb', line 201

def initialize(value)
  @bytes = value
  @bytes.force_encoding('binary')

  self
end

Instance Method Details

#estimate_sizeObject



224
225
226
# File 'lib/aerospike/value/value.rb', line 224

def estimate_size
  @bytes.bytesize
end

#getObject



212
213
214
# File 'lib/aerospike/value/value.rb', line 212

def get
  @bytes
end

#pack(packer) ⇒ Object



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

def pack(packer)
  packer.write(Aerospike::ParticleType::BLOB.chr + @bytes)
end

#to_bytesObject



220
221
222
# File 'lib/aerospike/value/value.rb', line 220

def to_bytes
  @bytes
end

#to_sObject



216
217
218
# File 'lib/aerospike/value/value.rb', line 216

def to_s
  @bytes.to_s
end

#typeObject



208
209
210
# File 'lib/aerospike/value/value.rb', line 208

def type
  Aerospike::ParticleType::BLOB
end

#write(buffer, offset) ⇒ Object



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

def write(buffer, offset)
  buffer.write_binary(@bytes, offset)
end