Class: Proj4::Unit

Inherits:
Def
  • Object
show all
Defined in:
lib/proj4.rb,
ext/projrb.c

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Def

#<=>, #==, get, #initialize, #to_s

Constructor Details

This class inherits a constructor from Proj4::Def

Class Method Details

.listObject

Return list of all units we know about.

call-seq: list -> Array of Proj4::Unit


435
436
437
438
439
440
441
442
# File 'ext/projrb.c', line 435

static VALUE unit_list(VALUE self){
  struct PJ_UNITS *unit;
  VALUE list = rb_ary_new();
  for (unit = pj_get_units_ref(); unit->id; unit++){
    rb_ary_push(list, Data_Wrap_Struct(cUnit, 0, 0, unit));
  }
  return list;
}

Instance Method Details

#idObject

Get ID of the unit.

call-seq: id -> String


448
449
450
451
452
# File 'ext/projrb.c', line 448

static VALUE unit_get_id(VALUE self){
  struct PJ_UNITS *unit;
  Data_Get_Struct(self,struct PJ_UNITS,unit);
  return rb_str_new2(unit->id);
}

#inspectObject

Returns unit definition as string in format ‘#<Proj4::Unit id=“…”, to_meter=“…”, name=“…”>’.

call-seq: inspect -> String



466
467
468
# File 'lib/proj4.rb', line 466

def inspect
  "#<Proj4::Unit id=\"#{id}\", to_meter=\"#{to_meter}\", name=\"#{name}\">"
end

#nameObject

Get name (description) of the unit.

call-seq: name -> String


468
469
470
471
472
# File 'ext/projrb.c', line 468

static VALUE unit_get_name(VALUE self){
  struct PJ_UNITS *unit;
  Data_Get_Struct(self,struct PJ_UNITS,unit);
  return rb_str_new2(unit->name);
}

#to_meterObject

Get conversion factor of this unit to a meter. Note that this is a string, it can either contain a floating point number or it can be in the form numerator/denominator.

call-seq: to_meter -> String


458
459
460
461
462
# File 'ext/projrb.c', line 458

static VALUE unit_get_to_meter(VALUE self){
  struct PJ_UNITS *unit;
  Data_Get_Struct(self,struct PJ_UNITS,unit);
  return rb_str_new2(unit->to_meter);
}