Class: Proj::Operation

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, description) ⇒ Operation

Returns a new instance of Operation.



22
23
24
25
# File 'lib/proj/operation.rb', line 22

def initialize(id, description)
  @id = id
  @description = description
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/proj/operation.rb', line 3

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/proj/operation.rb', line 3

def id
  @id
end

Class Method Details

.get(id) ⇒ Object



18
19
20
# File 'lib/proj/operation.rb', line 18

def self.get(id)
  self.list.find {|operation| operation.id == id}
end

.listObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/proj/operation.rb', line 5

def self.list
  pointer_to_array = FFI::Pointer.new(Api::PJ_LIST, Api.proj_list_operations)
  result = Array.new
  0.step do |i|
    operation_info = Api::PJ_LIST.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



27
28
29
# File 'lib/proj/operation.rb', line 27

def <=>(other)
  self.id <=> other.id
end

#==(other) ⇒ Object



31
32
33
# File 'lib/proj/operation.rb', line 31

def ==(other)
  self.id == other.id
end

#inspectObject



39
40
41
# File 'lib/proj/operation.rb', line 39

def inspect
  "#<#{self.class} id=\"#{id}\", major=\"#{major}\", ell=\"#{ell}\", name=\"#{name}\">"
end

#to_sObject



35
36
37
# File 'lib/proj/operation.rb', line 35

def to_s
  self.id
end