Class: Aerospike::GeoJSONValue

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

Overview

GeoJSON value. Supported by Aerospike server version 3.7 and later.

Instance Method Summary collapse

Methods inherited from Value

of, validate_hash_key

Constructor Details

#initialize(json) ⇒ GeoJSONValue

:nodoc:



490
491
492
493
494
# File 'lib/aerospike/value/value.rb', line 490

def initialize(json)
  @json = json
  @bytes = json.to_json
  self
end

Instance Method Details

#estimate_sizeObject



496
497
498
499
# File 'lib/aerospike/value/value.rb', line 496

def estimate_size
  # flags + ncells + jsonstr
  1 + 2 + @bytes.bytesize
end

#getObject



515
516
517
# File 'lib/aerospike/value/value.rb', line 515

def get
  @json
end

#pack(packer) ⇒ Object



507
508
509
# File 'lib/aerospike/value/value.rb', line 507

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

#to_bytesObject



519
520
521
# File 'lib/aerospike/value/value.rb', line 519

def to_bytes
  @bytes
end

#to_sObject



523
524
525
# File 'lib/aerospike/value/value.rb', line 523

def to_s
  @json
end

#typeObject



511
512
513
# File 'lib/aerospike/value/value.rb', line 511

def type
  Aerospike::ParticleType::GEOJSON
end

#write(buffer, offset) ⇒ Object



501
502
503
504
505
# File 'lib/aerospike/value/value.rb', line 501

def write(buffer, offset)
  buffer.write_byte(0, offset) # flags
  buffer.write_uint16(0, offset + 1) # ncells
  return 1 + 2 + buffer.write_binary(@bytes, offset + 3) # JSON string
end