Class: Tone::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/tone/client.rb

Overview

The primary interface for working with colorized text.

Instance Method Summary collapse

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_aliasObject



16
17
18
19
# File 'lib/tone/client.rb', line 16

def add_alias(...)
  aliaser.add(...)
  self
end

#aliasesObject



14
# File 'lib/tone/client.rb', line 14

def aliases = aliaser.to_h

#decodeObject



27
# File 'lib/tone/client.rb', line 27

def decode(...) = decoder.call(...)

#defaultsObject



12
# File 'lib/tone/client.rb', line 12

def defaults = aliaser.defaults

#encodeObject 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_aliasObject



21
# File 'lib/tone/client.rb', line 21

def get_alias(...) = aliaser.get(...)

#inspectObject



37
# File 'lib/tone/client.rb', line 37

def inspect = %(#<#{self.class} @encoder=#{encoder} @decoder=#{decoder} @aliaser=#{aliaser})