class Fir

Constants

VERSION

Attributes

key[R]
screen[R]

Public Class Methods

config() click to toggle source
# File lib/fir.rb, line 34
def self.config
  @config ||= {
    history: '~/.irb_history'
  }
end
new(key, screen) click to toggle source
# File lib/fir.rb, line 46
def initialize(key, screen)
  @key = key
  @screen = screen
end
parse_opts(output) click to toggle source
# File lib/fir.rb, line 24
def self.parse_opts(output)
  OptionParser.new do |cl_opts|
    cl_opts.banner = 'Usage: fir [options]'
    cl_opts.on('-v', '--version', 'Show version') do |v|
      config[:version] = v
    end
  end.parse!
  process_immediate_opts(config, output)
end
process_immediate_opts(opts, output) click to toggle source
# File lib/fir.rb, line 40
def self.process_immediate_opts(opts, output)
  return unless opts[:version]
  output.syswrite(Fir::VERSION)
  exit(0)
end
start(input, output, error) click to toggle source
# File lib/fir.rb, line 16
def self.start(input, output, error)
  parse_opts(output)
  new(
    Key.new(input),
    Screen.new(output, error)
  ).perform(ReplState.blank)
end

Public Instance Methods

perform(state) { |state| ... } click to toggle source
# File lib/fir.rb, line 51
def perform(state)
  state = yield(state) if block_given?
  perform(state) do
    state.transition(KeyCommand.for(key.get, state)) do |new_state|
      screen.update(state, new_state)
    end
  end
end