Class: Gm::Notepad::InputHandlers::CommentHandler

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

Constant Summary collapse

COMMENT_PREFIX =
'#'.freeze

Instance Attribute Summary

Attributes inherited from DefaultHandler

#expand_line, #input, #table_registry, #to_filesystem, #to_interactive, #to_output

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DefaultHandler

build_if_handled, #each_line_with_parameters, #initialize

Constructor Details

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

Class Method Details

.handles?(input:) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.handles?(input:)
  return false unless input[0] == COMMENT_PREFIX
  true
end

Instance Method Details

#after_initialize!Object



13
14
15
16
17
# File 'lib/gm/notepad/input_handlers/comment_handler.rb', line 13

def after_initialize!
  self.to_interactive = true
  self.to_output = false
  self.expand_line = false
end

#linesObject



19
20
21
# File 'lib/gm/notepad/input_handlers/comment_handler.rb', line 19

def lines
  [input]
end