Class: Numeric

Inherits:
Object
  • Object
show all
Includes:
Prawn::Measurements
Defined in:
lib/prawn/measurement_extensions.rb

Overview

Core extensions for Prawn::Measurements.

This mainly enables measurements DSL.

You have to explicitly require “prawn/measurement_extensions” to enable these.

require 'prawn/measurement_extensions'

12.mm
2.cm
0.5.in
4.yd + 2.ft

Experimental API collapse

Stable API collapse

Instance Method Details

#cmNumber

Convert from centimeters to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 37
37
def cm
38
  cm2pt(self)
39
end

#cm2mm(cm) ⇒ Number Originally defined in module Prawn::Measurements

Convert centimeter to millimeters.

Parameters:

  • cm (Number)

Returns:

  • (Number)

#cm2pt(cm) ⇒ Number Originally defined in module Prawn::Measurements

Convert centimeters to points.

Parameters:

  • cm (Number)

Returns:

  • (Number)

#dmNumber

Convert from decimeters to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 44
44
def dm
45
  dm2pt(self)
46
end

#dm2mm(dm) ⇒ Number Originally defined in module Prawn::Measurements

Convert decimeters to millimeters.

Parameters:

  • dm (Number)

Returns:

  • (Number)

#dm2pt(dm) ⇒ Number Originally defined in module Prawn::Measurements

Convert decimeters to points.

Parameters:

  • dm (Number)

Returns:

  • (Number)

#ftNumber

Convert from feet to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 72
72
def ft
73
  ft2pt(self)
74
end

#ft2in(ft) ⇒ Number Originally defined in module Prawn::Measurements

Convert feet to inches.

Parameters:

  • ft (Number)

Returns:

  • (Number)

#ft2pt(ft) ⇒ Number Originally defined in module Prawn::Measurements

Convert feet to points.

Parameters:

  • ft (Number)

Returns:

  • (Number)

#inNumber

Convert from inches to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 58
58
def in
59
  in2pt(self)
60
end

#in2pt(inch) ⇒ Number Originally defined in module Prawn::Measurements

Convert inches to points.

Parameters:

  • inch (Number)

Returns:

  • (Number)

#mNumber

Convert from meters to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 51
51
def m
52
  m2pt(self)
53
end

#m2mm(m) ⇒ Number Originally defined in module Prawn::Measurements

Convert meters to millimeters.

Parameters:

  • m (Number)

Returns:

  • (Number)

#m2pt(m) ⇒ Number Originally defined in module Prawn::Measurements

Convert meters to points.

Parameters:

  • m (Number)

Returns:

  • (Number)

#mmNumber

Convert from millimeters to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 30
30
def mm
31
  mm2pt(self)
32
end

#mm2pt(mm) ⇒ Number Originally defined in module Prawn::Measurements

Convert millimeters to points.

Parameters:

  • mm (Number)

Returns:

  • (Number)

#ptNumber

Convert from points to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 79
79
def pt
80
  pt2pt(self)
81
end

#pt2mm(pt) ⇒ Number Originally defined in module Prawn::Measurements

Convert points to millimeters.

Parameters:

  • pt (Number)

Returns:

  • (Number)

#pt2pt(pt) ⇒ Number Originally defined in module Prawn::Measurements

Convert points to points. For completeness.

Parameters:

  • pt (Number)

Returns:

  • (Number)

#ydNumber

Convert from yards to points.

Returns:

  • (Number)
Source Code
lib/prawn/measurement_extensions.rb, line 65
65
def yd
66
  yd2pt(self)
67
end

#yd2in(yd) ⇒ Number Originally defined in module Prawn::Measurements

Convert yards to inches.

Parameters:

  • yd (Number)

Returns:

  • (Number)

#yd2pt(yd) ⇒ Number Originally defined in module Prawn::Measurements

Convert yards to points.

Parameters:

  • yd (Number)

Returns:

  • (Number)