Class: ColorConverters::Color
- Inherits:
-
Object
- Object
- ColorConverters::Color
- Extended by:
- Forwardable
- Defined in:
- lib/color_converters/color.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(colour_input = nil, **kwargs) ⇒ Color
constructor
the two arguments mean we can support calling styles of a hash of colour keys, flattened hash, and string colour_input is nil when key-values are passed and must be pulled from the kwargs hash colour_input is set when a string is passed and kwargs is a hash of the extra options.
Constructor Details
#initialize(colour_input = nil, **kwargs) ⇒ Color
the two arguments mean we can support calling styles of a hash of colour keys, flattened hash, and string colour_input is nil when key-values are passed and must be pulled from the kwargs hash colour_input is set when a string is passed and kwargs is a hash of the extra options
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/color_converters/color.rb', line 11 def initialize(colour_input = nil, **kwargs) if colour_input.nil? colour_input = kwargs.except(:limit_override, :limit_clamp) kwargs = kwargs.slice(:limit_override, :limit_clamp) end @original_value = colour_input limit_override = kwargs.delete(:limit_override) || false limit_clamp = kwargs.delete(:limit_clamp) || false @converter = BaseConverter.factory(colour_input, limit_override, limit_clamp) end |
Instance Method Details
#==(other) ⇒ Object
25 26 27 28 29 |
# File 'lib/color_converters/color.rb', line 25 def ==(other) return false unless other.is_a?(Color) rgb == other.rgb && alpha == other.alpha end |