class TTYString::Code
Attributes
parser[R]
Public Class Methods
char(value = nil)
click to toggle source
# File lib/tty_string/code.rb, line 26 def char(value = nil) @char = value if value @char ||= name.split('::').last end
descendants()
click to toggle source
# File lib/tty_string/code.rb, line 6 def descendants @@descendants end
inherited(klass)
click to toggle source
Calls superclass method
# 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
new(parser)
click to toggle source
# File lib/tty_string/code.rb, line 46 def initialize(parser) @parser = parser end
render(parser)
click to toggle source
# File lib/tty_string/code.rb, line 18 def render(parser) return unless match?(parser) new(parser).action(*args(parser)) true end
Private Class Methods
args(_scanner)
click to toggle source
# File lib/tty_string/code.rb, line 37 def args(_scanner) [] end
match?(parser)
click to toggle source
# File lib/tty_string/code.rb, line 41 def match?(parser) parser.skip(re) end
re()
click to toggle source
# File lib/tty_string/code.rb, line 33 def re @re ||= /#{char}/.freeze end
Public Instance Methods
action()
click to toggle source
# File lib/tty_string/code.rb, line 50 def action; end
Private Instance Methods
cursor()
click to toggle source
# File lib/tty_string/code.rb, line 60 def cursor parser.cursor end
screen()
click to toggle source
# File lib/tty_string/code.rb, line 56 def screen parser.screen end