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.



977
978
979
980
981
982
983
984
985
# File 'lib/ffi-geos.rb', line 977

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.



975
976
977
# File 'lib/ffi-geos.rb', line 975

def ptr
  @ptr
end

Class Method Details

.release(ptr) ⇒ Object



987
988
989
# File 'lib/ffi-geos.rb', line 987

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

Instance Method Details

#error_handler(*args) ⇒ Object

Raises:

  • (RuntimeError)


995
996
997
# File 'lib/ffi-geos.rb', line 995

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

#notice_handler(*args) ⇒ Object



991
992
993
# File 'lib/ffi-geos.rb', line 991

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