Module RGhost::Units
In: units.rb

The postscript default unit is the 1/72th inch. RGhost uses the centimeters (cm) as it‘s default, mainly for positioning coordinates and numeric object sizes (if the size is a String, it won‘t be parsed to the default unit). This setting can be changed setting the value of RGhost::Config::GS[:unit] before the document is created using any of the Units child classes.


Setting to inches.

 doc.moveto :x => 1, :y => 2  #=> 1 inch x 2 inches

Explicitly setting to Cm.

 doc.moveto :x => '1 cm' , :y => '2 cm'

Using the Postscript unit

 doc.moveto :x => '100' , :y => '200'



Classes and Modules

Class RGhost::Units::Cm
Class RGhost::Units::Inch
Class RGhost::Units::PSUnit
Class RGhost::Units::Unit

Public Class methods

Parses units

 Units.parse(2)                #=> "2 cm"
 Units.parse(:current_row)     #=> "current_row"
 Units.parse("3 inch")         #=> "3 inch"
 Units.parse("2")              #=> "2"

Using US metric

  Units.parse(2)               #=> "2 inch"
  Units.parse(:current_row)    #=> "current_row"
  Units.parse("3 cm")          #=> "3 cm"
  Units.parse("5")             #=> "5"