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

Constructor Details

#initialize(json) ⇒ GeoJSONValue

:nodoc:



377
378
379
380
381
# File 'lib/aerospike/value/value.rb', line 377

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

Instance Method Details

#estimate_sizeObject



383
384
385
386
# File 'lib/aerospike/value/value.rb', line 383

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

#getObject



402
403
404
# File 'lib/aerospike/value/value.rb', line 402

def get
  @json
end

#pack(packer) ⇒ Object



394
395
396
# File 'lib/aerospike/value/value.rb', line 394

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

#to_bytesObject



406
407
408
# File 'lib/aerospike/value/value.rb', line 406

def to_bytes
  @bytes
end

#to_sObject



410
411
412
# File 'lib/aerospike/value/value.rb', line 410

def to_s
  @json
end

#typeObject



398
399
400
# File 'lib/aerospike/value/value.rb', line 398

def type
  Aerospike::ParticleType::GEOJSON
end

#write(buffer, offset) ⇒ Object



388
389
390
391
392
# File 'lib/aerospike/value/value.rb', line 388

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