Class: Proj::Operation
- Inherits:
-
Object
- Object
- Proj::Operation
- Defined in:
- lib/proj/operation.rb
Overview
Represents a PROJ operation (projection or conversion method). Each operation has an identifier and a human-readable description.
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ String
readonly
The operation identifier (e.g., “aea”, “merc”).
Class Method Summary collapse
-
.get(id) ⇒ Operation?
Finds an operation by its identifier.
-
.list ⇒ Array<Operation>
Returns a list of all available operations.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(id, description) ⇒ Operation
constructor
Creates a new Operation.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id, description) ⇒ Operation
Creates a new Operation.
50 51 52 53 |
# File 'lib/proj/operation.rb', line 50 def initialize(id, description) @id = id @description = description end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
17 |
# File 'lib/proj/operation.rb', line 17 attr_reader :id, :description |
#id ⇒ String (readonly)
Returns The operation identifier (e.g., “aea”, “merc”).
17 18 19 |
# File 'lib/proj/operation.rb', line 17 def id @id end |
Class Method Details
.get(id) ⇒ Operation?
Finds an operation by its identifier.
40 41 42 |
# File 'lib/proj/operation.rb', line 40 def self.get(id) self.list.find {|operation| operation.id == id} end |
.list ⇒ Array<Operation>
Returns a list of all available operations.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/proj/operation.rb', line 22 def self.list pointer_to_array = FFI::Pointer.new(Api::PjList, Api.proj_list_operations) result = Array.new 0.step do |i| operation_info = Api::PjList.new(pointer_to_array[i]) break result if operation_info[:id].nil? id = operation_info[:id] description = operation_info[:descr].read_pointer.read_string.force_encoding('UTF-8') result << self.new(id, description) end result end |
Instance Method Details
#==(other) ⇒ Object
55 56 57 |
# File 'lib/proj/operation.rb', line 55 def ==(other) self.id == other.id end |
#inspect ⇒ Object
63 64 65 |
# File 'lib/proj/operation.rb', line 63 def inspect "#<#{self.class} id=\"#{id}\", description=\"#{description}\">" end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/proj/operation.rb', line 59 def to_s self.id end |