Class: TTYString::Code

Inherits:
Object
  • Object
show all
Defined in:
lib/tty_string/code.rb,
lib/tty_string/code_definitions.rb

Direct Known Subclasses

CSICode, SlashA, SlashB, SlashN, SlashR, SlashT

Defined Under Namespace

Classes: SlashA, SlashB, SlashN, SlashR, SlashT

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ Code

Returns a new instance of Code.



46
47
48
# File 'lib/tty_string/code.rb', line 46

def initialize(parser)
  @parser = parser
end

Class Method Details

.char(value = nil) ⇒ Object



26
27
28
29
# File 'lib/tty_string/code.rb', line 26

def char(value = nil)
  @char = value if value
  @char ||= name.split('::').last
end

.descendantsObject



6
7
8
# File 'lib/tty_string/code.rb', line 6

def descendants
  @@descendants
end

.inherited(klass) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/tty_string/code.rb', line 10

def inherited(klass)
  @@descendants ||= [] # rubocop:disable Style/ClassVars I want it to be shared between subclasses.
  @@descendants << klass
  @@descendants.uniq!

  super
end

.render(parser) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/tty_string/code.rb', line 18

def render(parser)
  return unless match?(parser)

  new(parser).action(*args(parser))

  true
end

Instance Method Details

#actionObject



50
# File 'lib/tty_string/code.rb', line 50

def action; end