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.
69 70 71 72 |
# File 'lib/abachrome/color_space.rb', line 69 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.
62 63 64 |
# File 'lib/abachrome/color_space.rb', line 62 def color_model @color_model end |
#coordinates ⇒ Object
Returns the value of attribute coordinates.
62 63 64 |
# File 'lib/abachrome/color_space.rb', line 62 def coordinates @coordinates end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
62 63 64 |
# File 'lib/abachrome/color_space.rb', line 62 def name @name end |
#white_point ⇒ Object
Returns the value of attribute white_point.
62 63 64 |
# File 'lib/abachrome/color_space.rb', line 62 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.
50 51 52 |
# File 'lib/abachrome/color_space.rb', line 50 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.
57 58 59 |
# File 'lib/abachrome/color_space.rb', line 57 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.
38 39 40 |
# File 'lib/abachrome/color_space.rb', line 38 def register(name, &block) registry[name.to_sym] = new(name, &block) end |
.registry ⇒ Hash
A registry of all registered color spaces.
29 30 31 |
# File 'lib/abachrome/color_space.rb', line 29 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.
108 109 110 111 112 |
# File 'lib/abachrome/color_space.rb', line 108 def ==(other) return false unless other.is_a?(ColorSpace) name == other.name end |
#eql?(other) ⇒ Boolean
Checks if two color spaces are equal.
118 119 120 |
# File 'lib/abachrome/color_space.rb', line 118 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.
126 127 128 |
# File 'lib/abachrome/color_space.rb', line 126 def hash name.hash end |
#id ⇒ String, Symbol
Returns the identifier for the color space, which is currently the same as its name.
132 133 134 |
# File 'lib/abachrome/color_space.rb', line 132 def id name end |