Module: Sai::Registry Private
- Defined in:
- lib/sai/registry.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
The named color registry
Class Method Summary collapse
-
.[](name) ⇒ Array<Integer>
private
Look up an RGB value by color name.
-
.names ⇒ Array<Symbol>
private
Get a list of all color names.
-
.register(name, rgb_or_hex) ⇒ Boolean
private
Register a named color with an RGB or Hexadecimal value.
-
.subscribe(subscriber) ⇒ void
private
Subscribe to registry changes.
Class Method Details
.[](name) ⇒ Array<Integer>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Look up an RGB value by color name
23 24 25 |
# File 'lib/sai/registry.rb', line 23 def [](name) lookup[name.to_sym] end |
.names ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a list of all color names
35 36 37 |
# File 'lib/sai/registry.rb', line 35 def names @names ||= lookup.keys.uniq.sort end |
.register(name, rgb_or_hex) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Register a named color with an RGB or Hexadecimal value
51 52 53 54 55 56 57 |
# File 'lib/sai/registry.rb', line 51 def register(name, rgb_or_hex) key = name.to_s.downcase.to_sym rgb = Conversion::RGB.resolve(rgb_or_hex) thread_lock.synchronize { lookup[key] = rgb } broadcast_registration(key) true end |
.subscribe(subscriber) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Subscribe to registry changes
70 71 72 |
# File 'lib/sai/registry.rb', line 70 def subscribe(subscriber) thread_lock.synchronize { subscribers << subscriber } end |