class Fir::History

Attributes

active_selection[R]

Public Class Methods

add_line_to_history_file(line) click to toggle source
# File lib/fir/history.rb, line 47
def add_line_to_history_file(line)
  return unless history_file
  File.open(history_file, 'a') { |f| f.puts(line) }
end
history() click to toggle source
# File lib/fir/history.rb, line 39
def history
  if history_file && File.exist?(history_file)
    IO.readlines(history_file).map(&:chomp)
  else
    []
  end
end
history_file() click to toggle source
# File lib/fir/history.rb, line 34
def history_file
  @history_file ||= Fir.config[:history] &&
                    File.expand_path(Fir.config[:history])
end
new() click to toggle source
# File lib/fir/history.rb, line 10
def initialize
  @active_selection = 0
end

Public Instance Methods

down() click to toggle source
# File lib/fir/history.rb, line 22
def down
  @active_selection -= 1 if active_selection.positive?
end
reset() click to toggle source
# File lib/fir/history.rb, line 14
def reset
  @active_selection = 0
end
suggestion(line) click to toggle source
# File lib/fir/history.rb, line 26
def suggestion(line)
  Fir::Suggestion.new(
    line,
    Fir::History.history
  ).generate(active_selection)
end
up() click to toggle source
# File lib/fir/history.rb, line 18
def up
  @active_selection += 1
end