Class: Gm::Notepad::InputHandlers::WriteLineHandler

Inherits:
DefaultHandler show all
Defined in:
lib/gm/notepad/input_handlers/write_line_handler.rb

Constant Summary collapse

NON_EXPANDING_CHARATER =
'!'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DefaultHandler

build_if_handled, #initialize, #lines

Constructor Details

This class inherits a constructor from Gm::Notepad::InputHandlers::DefaultHandler

Class Method Details

.handles?(input:) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/gm/notepad/input_handlers/write_line_handler.rb', line 8

def self.handles?(input:)
  true
end

Instance Method Details

#after_initialize!Object



12
13
14
15
16
17
18
19
20
# File 'lib/gm/notepad/input_handlers/write_line_handler.rb', line 12

def after_initialize!
  if input[0] == NON_EXPANDING_CHARATER
    input.sub!(/^\!/,'')
    expand_line = false
  else
    expand_line = true
  end
  input.render_current_text(to_interactive: true, to_output: true, expand_line: expand_line)
end