Class: Gm::Notepad::InputHandlers::DefaultHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/gm/notepad/input_handlers/default_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input:, table_registry: nil) ⇒ DefaultHandler



14
15
16
17
18
19
20
21
22
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 14

def initialize(input:, table_registry: nil)
  self.to_interactive = false
  self.to_output = false
  self.to_filesystem = false
  self.expand_line = false
  self.input = input
  self.table_registry = table_registry
  after_initialize!
end

Instance Attribute Details

#expand_lineObject Also known as: expand_line?

Returns the value of attribute expand_line.



23
24
25
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 23

def expand_line
  @expand_line
end

#inputObject

Returns the value of attribute input.



23
24
25
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 23

def input
  @input
end

#table_registryObject

Returns the value of attribute table_registry.



23
24
25
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 23

def table_registry
  @table_registry
end

#to_filesystemObject

Returns the value of attribute to_filesystem.



23
24
25
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 23

def to_filesystem
  @to_filesystem
end

#to_interactiveObject

Returns the value of attribute to_interactive.



23
24
25
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 23

def to_interactive
  @to_interactive
end

#to_outputObject

Returns the value of attribute to_output.



23
24
25
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 23

def to_output
  @to_output
end

Class Method Details

.build_if_handled(input:) ⇒ Object



5
6
7
8
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 5

def self.build_if_handled(input:)
  return false unless handles?(input: input)
  new(input: input)
end

.handles?(input:) ⇒ Boolean



10
11
12
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 10

def self.handles?(input:)
  true
end

Instance Method Details

#after_initialize!Object



25
26
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 25

def after_initialize!
end

#each_line_with_parametersObject



34
35
36
37
38
39
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 34

def each_line_with_parameters
  lines.each do |line|
    line = table_registry.evaluate(line: line.to_s.strip) if expand_line?
    yield(line, to_output: to_output, to_interactive: to_interactive)
  end
end

#linesObject



28
29
30
# File 'lib/gm/notepad/input_handlers/default_handler.rb', line 28

def lines
  []
end