Module: Prawn::Measurements

Included in:
Numeric
Defined in:
lib/prawn/measurements.rb

Overview

Distance unit conversions between metric, imperial, and PDF.

Stable API collapse

Instance Method Details

#cm2mm(cm) ⇒ Number

Convert centimeter to millimeters.

Parameters:

  • cm (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 15
15
def cm2mm(cm)
16
  cm * 10
17
end

#cm2pt(cm) ⇒ Number

Convert centimeters to points.

Parameters:

  • cm (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 100
100
def cm2pt(cm)
101
  mm2pt(cm2mm(cm))
102
end

#dm2mm(dm) ⇒ Number

Convert decimeters to millimeters.

Parameters:

  • dm (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 23
23
def dm2mm(dm)
24
  dm * 100
25
end

#dm2pt(dm) ⇒ Number

Convert decimeters to points.

Parameters:

  • dm (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 108
108
def dm2pt(dm)
109
  mm2pt(dm2mm(dm))
110
end

#ft2in(ft) ⇒ Number

Convert feet to inches.

Parameters:

  • ft (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 42
42
def ft2in(ft)
43
  ft * 12
44
end

#ft2pt(ft) ⇒ Number

Convert feet to points.

Parameters:

  • ft (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 76
76
def ft2pt(ft)
77
  in2pt(ft2in(ft))
78
end

#in2pt(inch) ⇒ Number

Convert inches to points.

Parameters:

  • inch (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 68
68
def in2pt(inch)
69
  inch * 72
70
end

#m2mm(m) ⇒ Number

Convert meters to millimeters.

Parameters:

  • m (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 31
31
def m2mm(m)
32
  m * 1000
33
end

#m2pt(m) ⇒ Number

Convert meters to points.

Parameters:

  • m (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 116
116
def m2pt(m)
117
  mm2pt(m2mm(m))
118
end

#mm2pt(mm) ⇒ Number

Convert millimeters to points.

Parameters:

  • mm (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 92
92
def mm2pt(mm)
93
  mm * (72 / 25.4)
94
end

#pt2mm(pt) ⇒ Number

Convert points to millimeters.

Parameters:

  • pt (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 124
124
def pt2mm(pt)
125
  pt * 1 / mm2pt(1) # (25.4 / 72)
126
end

#pt2pt(pt) ⇒ Number

Convert points to points. For completeness.

Parameters:

  • pt (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 60
60
def pt2pt(pt)
61
  pt
62
end

#yd2in(yd) ⇒ Number

Convert yards to inches.

Parameters:

  • yd (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 50
50
def yd2in(yd)
51
  yd * 36
52
end

#yd2pt(yd) ⇒ Number

Convert yards to points.

Parameters:

  • yd (Number)

Returns:

  • (Number)
Source Code
lib/prawn/measurements.rb, line 84
84
def yd2pt(yd)
85
  in2pt(yd2in(yd))
86
end