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.

Constant Summary

Constants inherited from Value

Value::INTEGER_RANGE

Instance Method Summary collapse

Methods inherited from Value

of

Constructor Details

#initialize(json) ⇒ GeoJSONValue

:nodoc:



460
461
462
463
464
# File 'lib/aerospike/value/value.rb', line 460

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

Instance Method Details

#estimate_sizeObject



466
467
468
469
# File 'lib/aerospike/value/value.rb', line 466

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

#getObject



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

def get
  @json
end

#pack(packer) ⇒ Object



477
478
479
# File 'lib/aerospike/value/value.rb', line 477

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

#to_bytesObject



489
490
491
# File 'lib/aerospike/value/value.rb', line 489

def to_bytes
  @bytes
end

#to_sObject



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

def to_s
  @json
end

#typeObject



481
482
483
# File 'lib/aerospike/value/value.rb', line 481

def type
  Aerospike::ParticleType::GEOJSON
end

#write(buffer, offset) ⇒ Object



471
472
473
474
475
# File 'lib/aerospike/value/value.rb', line 471

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