Class: Laser::Cutter::UnitsConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/laser/cutter/units_converter.rb

Overview

Converts lengths between millimetres and inches, rounded to five digits.

Class Method Summary collapse

Class Method Details

.in2mm(value) ⇒ Float

Returns the same length in millimetres.

Parameters:

  • value (Numeric) —

    a length in inches

Returns:

  • (Float) —

    the same length in millimetres



15
16
17
# File 'lib/laser/cutter/units_converter.rb', line 15

def self.in2mm(value)
  (25.4 * value).round(5)
end

.mm2in(value) ⇒ Float

Returns the same length in inches.

Parameters:

  • value (Numeric) —

    a length in millimetres

Returns:

  • (Float) —

    the same length in inches



9
10
11
# File 'lib/laser/cutter/units_converter.rb', line 9

def self.mm2in(value)
  (0.039370079 * value).round(5)
end