Parent

Class/Module Index [+]

Quicksearch

HammerCLI::ShellHistory

Public Class Methods

new(history_file_path) click to toggle source
# File lib/hammer_cli/shell.rb, line 42
def initialize(history_file_path)
  @file_path = history_file_path
  load
end

Public Instance Methods

ingonred_commands() click to toggle source
# File lib/hammer_cli/shell.rb, line 57
def ingonred_commands
  ["exit"]
end
push(line) click to toggle source
# File lib/hammer_cli/shell.rb, line 47
def push(line)
  line.strip!
  return if line.empty? or ingonred_commands.include?(line)

  Readline::HISTORY.push(line)
  File.open(file_path, "a") do |f|
    f.puts(line)
  end
end

Protected Instance Methods

file_path() click to toggle source
# File lib/hammer_cli/shell.rb, line 63
def file_path
  File.expand_path(@file_path)
end
load() click to toggle source
# File lib/hammer_cli/shell.rb, line 67
def load
  if File.exist?(file_path)
    File.readlines(file_path).each do |line|
      Readline::HISTORY.push(line.strip)
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.