Class: Vedeu::Colours::Repository Private
- Inherits:
-
Object
- Object
- Vedeu::Colours::Repository
- Defined in:
- lib/vedeu/colours/repository.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Allows the storing of HTML/CSS colours and their respective escape sequences.
Direct Known Subclasses
Instance Attribute Summary collapse
- #storage ⇒ Hash<String => String> (also: #all) readonly private
Instance Method Summary collapse
-
#initialize ⇒ Vedeu::Colours::Repository
constructor
private
Returns a new instance of Vedeu::Colours::Repository.
-
#register(colour, escape_sequence) ⇒ String
private
Registers a colour with respective escape sequence.
-
#registered?(colour) ⇒ Boolean
private
Returns a boolean indicating whether the colour has been sregistered.
-
#reset! ⇒ Hash
private
Removes all stored colours.
-
#retrieve(colour) ⇒ String
private
Retrieves the escape sequence of a registered colour.
Constructor Details
#initialize ⇒ Vedeu::Colours::Repository
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.
Returns a new instance of Vedeu::Colours::Repository.
22 23 24 |
# File 'lib/vedeu/colours/repository.rb', line 22 def initialize @storage = {} end |
Instance Attribute Details
#storage ⇒ Hash<String => String> (readonly) Also known as: all
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.
16 17 18 |
# File 'lib/vedeu/colours/repository.rb', line 16 def storage @storage end |
Instance Method Details
#register(colour, escape_sequence) ⇒ String
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.
Registers a colour with respective escape sequence.
29 30 31 |
# File 'lib/vedeu/colours/repository.rb', line 29 def register(colour, escape_sequence) storage.store(colour, escape_sequence) end |
#registered?(colour) ⇒ 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.
Returns a boolean indicating whether the colour has been sregistered.
38 39 40 41 42 |
# File 'lib/vedeu/colours/repository.rb', line 38 def registered?(colour) return false unless colour storage.key?(colour) end |
#reset! ⇒ Hash
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.
Removes all stored colours.
47 48 49 |
# File 'lib/vedeu/colours/repository.rb', line 47 def reset! storage.clear end |
#retrieve(colour) ⇒ String
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.
Retrieves the escape sequence of a registered colour.
54 55 56 |
# File 'lib/vedeu/colours/repository.rb', line 54 def retrieve(colour) storage.fetch(colour, '') end |