Class: Aerospike::IntegerValue

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

Overview

Integer value.

Instance Method Summary collapse

Methods inherited from Value

of, validate_hash_key

Constructor Details

#initialize(val) ⇒ IntegerValue

:nodoc:



291
292
293
294
# File 'lib/aerospike/value/value.rb', line 291

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

Instance Method Details

#estimate_sizeObject



296
297
298
# File 'lib/aerospike/value/value.rb', line 296

def estimate_size
  8
end

#getObject



313
314
315
# File 'lib/aerospike/value/value.rb', line 313

def get
  @value
end

#pack(packer) ⇒ Object



305
306
307
# File 'lib/aerospike/value/value.rb', line 305

def pack(packer)
  packer.write(@value)
end

#to_bytesObject



317
318
319
320
321
# File 'lib/aerospike/value/value.rb', line 317

def to_bytes
  # Convert integer to big endian unsigned 64 bits.
  # @see http://ruby-doc.org/core-2.3.0/Array.html#method-i-pack
  [@value].pack("Q>")
end

#to_sObject



323
324
325
# File 'lib/aerospike/value/value.rb', line 323

def to_s
  @value.to_s
end

#typeObject



309
310
311
# File 'lib/aerospike/value/value.rb', line 309

def type
  Aerospike::ParticleType::INTEGER
end

#write(buffer, offset) ⇒ Object



300
301
302
303
# File 'lib/aerospike/value/value.rb', line 300

def write(buffer, offset)
  buffer.write_int64(@value, offset)
  8
end