Class: ColorContrastCalc::ColorFunctionParser::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/color_contrast_calc/color_function_parser.rb

Overview

Hold information about a parsed RGB/HSL/HWB function.

This class is intended to be used internally in ColorFunctionParser, so do not rely on the current class name and its interfaces. They may change in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#schemeString (readonly)

Returns Type of function: ‘rgb’ or ‘hsl’.

Returns:

  • (String)

    Type of function: ‘rgb’ or ‘hsl’



168
169
170
# File 'lib/color_contrast_calc/color_function_parser.rb', line 168

def scheme
  @scheme
end

#sourceObject (readonly)

Returns the value of attribute source.



168
# File 'lib/color_contrast_calc/color_function_parser.rb', line 168

attr_reader :scheme, :source

Instance Method Details

#rgbArray<Integer>

Return the RGB value gained from a RGB/HSL/HWB function.

Returns:

  • (Array<Integer>)

    RGB value represented as an array

Raises:

  • (NotImplementedError)


195
196
197
# File 'lib/color_contrast_calc/color_function_parser.rb', line 195

def rgb
  raise NotImplementedError, 'Overwrite the method in a subclass'
end

#to_aArray<Integer, Float>

Return the parameters of a RGB/HSL/HWB function as an array of Integer/Float. The unit for H, S, L is assumed to be deg, %, % respectively.

Returns:

  • (Array<Integer, Float>)

    RGB/HSL/HWB value represented as an array



207
208
209
# File 'lib/color_contrast_calc/color_function_parser.rb', line 207

def to_a
  @normalized
end