Class: CssColorContrast::CommandInterpreter::Function::AdjustLightness

Inherits:
CssColorContrast::CommandInterpreter::Function show all
Defined in:
lib/css_color_contrast/command_interpreter.rb

Constant Summary collapse

DEFAULT_RATIO =
4.5

Instance Attribute Summary

Attributes inherited from CssColorContrast::CommandInterpreter::Function

#name, #params

Instance Method Summary collapse

Methods inherited from CssColorContrast::CommandInterpreter::Function

create, #initialize, #param_values, #push

Constructor Details

This class inherits a constructor from CssColorContrast::CommandInterpreter::Function

Instance Method Details

#evaluateObject



71
72
73
74
75
76
77
# File 'lib/css_color_contrast/command_interpreter.rb', line 71

def evaluate
  fixed, to_adjust, ratio = param_values

  ratio = ratio_given(ratio) ? ratio.to_f : DEFAULT_RATIO

  CssColorContrast.adjust_lightness(fixed, to_adjust, ratio)
end

#ratio_given(ratio) ⇒ Object



67
68
69
# File 'lib/css_color_contrast/command_interpreter.rb', line 67

def ratio_given(ratio)
  ratio && /\A\d+(\.\d+)?/.match?(ratio)
end