Class: Geos::Handle

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi-geos.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHandle

Returns a new instance of Handle.



1007
1008
1009
1010
1011
1012
1013
1014
1015
# File 'lib/ffi-geos.rb', line 1007

def initialize
  @ptr = FFI::AutoPointer.new(
    FFIGeos.initGEOS_r(
      @notice_handler = self.method(:notice_handler),
      @error_handler = self.method(:error_handler)
    ),
    self.class.method(:release)
  )
end

Instance Attribute Details

#ptrObject (readonly)

Returns the value of attribute ptr.



1005
1006
1007
# File 'lib/ffi-geos.rb', line 1005

def ptr
  @ptr
end

Class Method Details

.release(ptr) ⇒ Object



1017
1018
1019
# File 'lib/ffi-geos.rb', line 1017

def self.release(ptr)
  FFIGeos.finishGEOS_r(ptr)
end

Instance Method Details

#error_handler(*args) ⇒ Object

Raises:

  • (RuntimeError)


1025
1026
1027
# File 'lib/ffi-geos.rb', line 1025

def error_handler(*args)
  raise RuntimeError.new(args[0] % args[1])
end

#notice_handler(*args) ⇒ Object



1021
1022
1023
# File 'lib/ffi-geos.rb', line 1021

def notice_handler(*args)
  # no-op, just to appease initGEOS.
end