Class: Tone::Client
- Inherits:
-
Object
- Object
- Tone::Client
- Defined in:
- lib/tone/client.rb
Overview
The primary interface for working with colorized text.
Instance Method Summary collapse
- #add_alias ⇒ Object
- #aliases ⇒ Object
- #decode ⇒ Object
- #defaults ⇒ Object
- #encode ⇒ Object (also: #[])
- #find_code(key) ⇒ Object
- #find_codes(*keys) ⇒ Object
- #find_symbol(code) ⇒ Object
- #find_symbols(*codes) ⇒ Object
- #get_alias ⇒ Object
-
#initialize(enabled: $stdout.tty?, container: Tone::CONTAINER) ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
Constructor Details
#initialize(enabled: $stdout.tty?, container: Tone::CONTAINER) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/tone/client.rb', line 6 def initialize enabled: $stdout.tty?, container: Tone::CONTAINER @aliaser = container.fetch(:aliaser).new defaults: container.fetch(:defaults) @encoder = container.fetch(:encoder).new(aliaser:, enabled:) @decoder = container.fetch(:decoder).new defaults: aliaser.defaults end |
Instance Method Details
#add_alias ⇒ Object
16 17 18 19 |
# File 'lib/tone/client.rb', line 16 def add_alias(...) aliaser.add(...) self end |
#aliases ⇒ Object
14 |
# File 'lib/tone/client.rb', line 14 def aliases = aliaser.to_h |
#decode ⇒ Object
27 |
# File 'lib/tone/client.rb', line 27 def decode(...) = decoder.call(...) |
#defaults ⇒ Object
12 |
# File 'lib/tone/client.rb', line 12 def defaults = aliaser.defaults |
#encode ⇒ Object Also known as: []
23 |
# File 'lib/tone/client.rb', line 23 def encode(...) = encoder.call(...) |
#find_code(key) ⇒ Object
29 |
# File 'lib/tone/client.rb', line 29 def find_code(key) = defaults[key] |
#find_codes(*keys) ⇒ Object
31 |
# File 'lib/tone/client.rb', line 31 def find_codes(*keys) = defaults.values_at(*keys) |
#find_symbol(code) ⇒ Object
33 |
# File 'lib/tone/client.rb', line 33 def find_symbol(code) = defaults.invert[code] |
#find_symbols(*codes) ⇒ Object
35 |
# File 'lib/tone/client.rb', line 35 def find_symbols(*codes) = defaults.invert.values_at(*codes) |
#get_alias ⇒ Object
21 |
# File 'lib/tone/client.rb', line 21 def get_alias(...) = aliaser.get(...) |
#inspect ⇒ Object
37 |
# File 'lib/tone/client.rb', line 37 def inspect = %(#<#{self.class} @encoder=#{encoder} @decoder=#{decoder} @aliaser=#{aliaser}) |