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


441
442
443
444
445
446
447
448
# File 'ext/projrb.c', line 441

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


454
455
456
457
458
# File 'ext/projrb.c', line 454

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



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

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

#nameObject

Get name (description) of the unit.

call-seq: name -> String


474
475
476
477
478
# File 'ext/projrb.c', line 474

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


464
465
466
467
468
# File 'ext/projrb.c', line 464

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);
}