Class: ColorCalculator::Calculation::DeltaE2000

Inherits:
Object
  • Object
show all
Defined in:
lib/color_calculator/calculation/delta_e_2000.rb

Constant Summary collapse

K_OF_L =
1
K_OF_C =
1
K_OF_H =
1

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sample, reference) ⇒ DeltaE2000

Returns a new instance of DeltaE2000.



19
20
21
22
# File 'lib/color_calculator/calculation/delta_e_2000.rb', line 19

def initialize(sample, reference)
  @sample = sample
  @reference = reference
end

Class Method Details

.call(*args) ⇒ Object



10
11
12
# File 'lib/color_calculator/calculation/delta_e_2000.rb', line 10

def call(*args)
  new(*args).call
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/color_calculator/calculation/delta_e_2000.rb', line 24

def call
  Math.sqrt(
    [
      Rational(delta_l_prime, K_OF_L * s_of_l) ** 2,
      Rational(delta_c_prime, K_OF_C * s_of_c) ** 2,
      Rational(delta_h_prime, K_OF_H * s_of_h) ** 2,
      [
        r_of_t,
        Rational(delta_c_prime, K_OF_C * s_of_c),
        Rational(delta_h_prime, K_OF_H * s_of_h),
      ].reduce(:*)
    ].reduce(:+)
  )
end