Class: Proj::PjObjects

Inherits:
Object
  • Object
show all
Defined in:
lib/proj/pj_objects.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pointer, context) ⇒ PjObjects

Returns a new instance of PjObjects.



10
11
12
13
14
# File 'lib/proj/pj_objects.rb', line 10

def initialize(pointer, context)
  @pointer = pointer
  @context = context
  ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
end

Class Method Details

.finalize(pointer) ⇒ Object



4
5
6
7
8
# File 'lib/proj/pj_objects.rb', line 4

def self.finalize(pointer)
  proc do
    Api.proj_list_destroy(pointer)
  end
end

Instance Method Details

#[](index) ⇒ Object



29
30
31
32
# File 'lib/proj/pj_objects.rb', line 29

def [](index)
  ptr = Api.proj_list_get(context, self, index)
  PjObject.create_object(ptr, self.context)
end

#contextObject



20
21
22
# File 'lib/proj/pj_objects.rb', line 20

def context
  @context || Context.current
end

#countObject Also known as: size



24
25
26
# File 'lib/proj/pj_objects.rb', line 24

def count
  Api.proj_list_get_count(self)
end

#suggested_operation(direction, coord) ⇒ Integer

Returns the index of the operation that would be the most appropriate to transform the specified coordinates.

Parameters:

  • direction (PJ_DIRECTION)
    • Direction into which to transform the point.

  • coord (Coordinate)
    • Coordinate to transform

Returns:

  • (Integer)
    • Index of operation



40
41
42
# File 'lib/proj/pj_objects.rb', line 40

def suggested_operation(direction, coord)
  Api.proj_get_suggested_operation(self.context, self, direction, coord)
end

#to_ptrObject



16
17
18
# File 'lib/proj/pj_objects.rb', line 16

def to_ptr
  @pointer
end