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:



485
486
487
488
489
# File 'lib/aerospike/value/value.rb', line 485

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

Instance Method Details

#estimate_sizeObject



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

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

#getObject



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

def get
  @json
end

#pack(packer) ⇒ Object



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

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

#to_bytesObject



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

def to_bytes
  @bytes
end

#to_sObject



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

def to_s
  @json
end

#typeObject



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

def type
  Aerospike::ParticleType::GEOJSON
end

#write(buffer, offset) ⇒ Object



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

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