Class: Abachrome::ColorSpace
- Inherits:
-
Object
- Object
- Abachrome::ColorSpace
- Defined in:
- lib/abachrome/color_space.rb
Instance Attribute Summary collapse
-
#color_model ⇒ Object
Returns the value of attribute color_model.
-
#coordinates ⇒ Object
Returns the value of attribute coordinates.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#white_point ⇒ Object
Returns the value of attribute white_point.
Class Method Summary collapse
-
.alias(name, aliased_name) ⇒ void
Aliases a color space name to an existing registered color space.
-
.find(name) ⇒ Abachrome::ColorSpace
The color space with the given name.
-
.register(name, &block) ⇒ Abachrome::ColorSpace
Registers a new color space with the specified name.
-
.registry ⇒ Hash
A registry of all registered color spaces.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares this ColorSpace instance with another to check for equality.
-
#eql?(other) ⇒ Boolean
Checks if two color spaces are equal.
-
#hash ⇒ Integer
Returns a hash value for the color space based on its name.
-
#id ⇒ String, Symbol
Returns the identifier for the color space, which is currently the same as its name.
-
#initialize(name) {|self| ... } ⇒ Abachrome::ColorSpace
constructor
Initialize a new ColorSpace instance.
Constructor Details
#initialize(name) {|self| ... } ⇒ Abachrome::ColorSpace
Initialize a new ColorSpace instance.
67 68 69 70 |
# File 'lib/abachrome/color_space.rb', line 67 def initialize(name) @name = name.to_sym yield self if block_given? end |
Instance Attribute Details
#color_model ⇒ Object
Returns the value of attribute color_model.
60 61 62 |
# File 'lib/abachrome/color_space.rb', line 60 def color_model @color_model end |
#coordinates ⇒ Object
Returns the value of attribute coordinates.
60 61 62 |
# File 'lib/abachrome/color_space.rb', line 60 def coordinates @coordinates end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
60 61 62 |
# File 'lib/abachrome/color_space.rb', line 60 def name @name end |
#white_point ⇒ Object
Returns the value of attribute white_point.
60 61 62 |
# File 'lib/abachrome/color_space.rb', line 60 def white_point @white_point end |
Class Method Details
.alias(name, aliased_name) ⇒ void
This method returns an undefined value.
Aliases a color space name to an existing registered color space.
This method creates an alias for an existing color space in the registry, allowing the same color space to be accessed through multiple names.
48 49 50 |
# File 'lib/abachrome/color_space.rb', line 48 def alias(name, aliased_name) registry[aliased_name.to_sym] = registry[name.to_sym] end |
.find(name) ⇒ Abachrome::ColorSpace
Returns The color space with the given name.
55 56 57 |
# File 'lib/abachrome/color_space.rb', line 55 def find(name) registry[name.to_sym] or raise ArgumentError, "Unknown color space: #{name}" end |
.register(name, &block) ⇒ Abachrome::ColorSpace
Registers a new color space with the specified name.
36 37 38 |
# File 'lib/abachrome/color_space.rb', line 36 def register(name, &block) registry[name.to_sym] = new(name, &block) end |
.registry ⇒ Hash
A registry of all registered color spaces.
27 28 29 |
# File 'lib/abachrome/color_space.rb', line 27 def registry @registry ||= {} end |
Instance Method Details
#==(other) ⇒ Boolean
Compares this ColorSpace instance with another to check for equality.
Two ColorSpace objects are considered equal if they have the same name.
106 107 108 109 110 |
# File 'lib/abachrome/color_space.rb', line 106 def ==(other) return false unless other.is_a?(ColorSpace) name == other.name end |
#eql?(other) ⇒ Boolean
Checks if two color spaces are equal.
116 117 118 |
# File 'lib/abachrome/color_space.rb', line 116 def eql?(other) self == other end |
#hash ⇒ Integer
Returns a hash value for the color space based on its name.
used for equality comparison and as a hash key.
124 125 126 |
# File 'lib/abachrome/color_space.rb', line 124 def hash name.hash end |
#id ⇒ String, Symbol
Returns the identifier for the color space, which is currently the same as its name.
130 131 132 |
# File 'lib/abachrome/color_space.rb', line 130 def id name end |