Class: Vedeu::Colours::Repository Private

Inherits:
Object
  • Object
show all
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

Backgrounds, Foregrounds

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVedeu::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

#storageHash<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.

Returns:

  • (Hash<String => String>)


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.

Returns:

  • (String)


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.

Parameters:

  • colour (String)

Returns:



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.

Returns:

  • (Hash)


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.

Returns:

  • (String)


54
55
56
# File 'lib/vedeu/colours/repository.rb', line 54

def retrieve(colour)
  storage.fetch(colour, '')
end