class Gm::Notepad::App

Responsible for recording entries and then dumping them accordingly.

Attributes

input_processor[R]
renderer[R]

Public Class Methods

new(*args, input_processor: nil, renderer: nil) click to toggle source
Calls superclass method
# File lib/gm/notepad/app.rb, line 16
def initialize(*args, input_processor: nil, renderer: nil)
  super
  # Note: I could note use Dry::Initializer.option with Container as I ended
  # up with multiple table registry objects created. Which is why I'm using the
  # keyword's with nil, so I can set two elements after the table_registry is "resolved"
  @renderer = renderer || LineRenderer.new(table_registry: table_registry)
  @input_processor = input_processor || InputProcessor.new(table_registry: table_registry)
  open!
end

Public Instance Methods

close!() click to toggle source
# File lib/gm/notepad/app.rb, line 32
def close!
  renderer.close!
end
process(text:) click to toggle source
# File lib/gm/notepad/app.rb, line 27
def process(text:)
  output = input_processor.convert_to_output(input: text)
  renderer.render(output: output)
end

Private Instance Methods

open!() click to toggle source
# File lib/gm/notepad/app.rb, line 38
def open!
  renderer.call("Welcome to gm-notepad. type \"?\" for help.", to_interactive: true, to_output: false)
  return unless report_config
  lines = ["# Configuration Parameters:"]
  Config.settings.each do |setting|
    lines << "#   config[#{setting.inspect}] = #{Config.public_send(setting).inspect}"
  end
  # When running :list_tables by default I don't want to report
  # that to the output buffer.
  to_output = !list_tables
  renderer.call(lines, to_interactive: true, to_output: to_output)
end