Class: Proj::Unit
- Inherits:
-
Object
- Object
- Proj::Unit
- Defined in:
- lib/unit.rb
Instance Attribute Summary collapse
-
#factor ⇒ Object
readonly
Returns the value of attribute factor.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#to_meter ⇒ Object
readonly
Returns the value of attribute to_meter.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(id, to_meter, factor, name) ⇒ Unit
constructor
A new instance of Unit.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(id, to_meter, factor, name) ⇒ Unit
Returns a new instance of Unit.
31 32 33 34 35 36 |
# File 'lib/unit.rb', line 31 def initialize(id, to_meter, factor, name) @id = id @to_meter = to_meter @factor = factor @name = name end |
Instance Attribute Details
#factor ⇒ Object (readonly)
Returns the value of attribute factor.
3 4 5 |
# File 'lib/unit.rb', line 3 def factor @factor end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/unit.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/unit.rb', line 3 def name @name end |
#to_meter ⇒ Object (readonly)
Returns the value of attribute to_meter.
3 4 5 |
# File 'lib/unit.rb', line 3 def to_meter @to_meter end |
Class Method Details
.get(id) ⇒ Object
27 28 29 |
# File 'lib/unit.rb', line 27 def self.get(id) self.list.find {|ellipsoid| ellipsoid.id == id} end |
.list ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/unit.rb', line 5 def self.list # First get linear units pointer_to_array = FFI::Pointer.new(Api::PJ_UNITS, Api.proj_list_units) result = Array.new 0.step do |i| ellipse_info = Api::PJ_UNITS.new(pointer_to_array[i]) break if ellipse_info[:id].nil? result << self.new(ellipse_info[:id], ellipse_info[:to_meter], ellipse_info[:factor], ellipse_info[:name]) end # Now get angular linear units if Api.method_defined?(:proj_list_angular_units) pointer_to_array = FFI::Pointer.new(Api::PJ_UNITS, Api.proj_list_angular_units) 0.step do |i| ellipse_info = Api::PJ_UNITS.new(pointer_to_array[i]) break result if ellipse_info[:id].nil? result << self.new(ellipse_info[:id], ellipse_info[:to_meter], ellipse_info[:factor], ellipse_info[:name]) end end result end |
Instance Method Details
#<=>(other) ⇒ Object
38 39 40 |
# File 'lib/unit.rb', line 38 def <=>(other) self.id <=> other.id end |
#==(other) ⇒ Object
42 43 44 |
# File 'lib/unit.rb', line 42 def ==(other) self.id == other.id end |
#inspect ⇒ Object
50 51 52 |
# File 'lib/unit.rb', line 50 def inspect "#<#{self.class} id=\"#{id}\", to_meter=\"#{to_meter}\", factor=\"#{factor}\", name=\"#{name}\">" end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/unit.rb', line 46 def to_s self.id end |