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.

“‘ruby 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)


37
38
39
# File 'lib/prawn/measurement_extensions.rb', line 37

def cm
  cm2pt(self)
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)


44
45
46
# File 'lib/prawn/measurement_extensions.rb', line 44

def dm
  dm2pt(self)
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)


72
73
74
# File 'lib/prawn/measurement_extensions.rb', line 72

def ft
  ft2pt(self)
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)


58
59
60
# File 'lib/prawn/measurement_extensions.rb', line 58

def in
  in2pt(self)
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)


51
52
53
# File 'lib/prawn/measurement_extensions.rb', line 51

def m
  m2pt(self)
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)


30
31
32
# File 'lib/prawn/measurement_extensions.rb', line 30

def mm
  mm2pt(self)
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)


79
80
81
# File 'lib/prawn/measurement_extensions.rb', line 79

def pt
  pt2pt(self)
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)


65
66
67
# File 'lib/prawn/measurement_extensions.rb', line 65

def yd
  yd2pt(self)
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)