Class: HammerCLI::ShellHistory
- Inherits:
-
Object
- Object
- HammerCLI::ShellHistory
- Defined in:
- lib/hammer_cli/shell.rb
Instance Method Summary collapse
- #ingonred_commands ⇒ Object
-
#initialize(history_file_path) ⇒ ShellHistory
constructor
A new instance of ShellHistory.
- #push(line) ⇒ Object
Constructor Details
#initialize(history_file_path) ⇒ ShellHistory
Returns a new instance of ShellHistory.
42 43 44 45 |
# File 'lib/hammer_cli/shell.rb', line 42 def initialize(history_file_path) @file_path = history_file_path load end |
Instance Method Details
#ingonred_commands ⇒ Object
57 58 59 |
# File 'lib/hammer_cli/shell.rb', line 57 def ingonred_commands ["exit"] end |
#push(line) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# 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 |