Class: Qcmd::History

Inherits:
Object
  • Object
show all
Defined in:
lib/qcmd/history.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.commandsObject

Returns the value of attribute commands.



4
5
6
# File 'lib/qcmd/history.rb', line 4

def commands
  @commands
end

Class Method Details

.loadObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/qcmd/history.rb', line 6

def load
  if File.exists?(Qcmd::Configuration.history_file)
    lines = File.new(Qcmd::Configuration.history_file, 'r').readlines
  else
    lines = []
  end

  if lines
    lines.reverse[0..100].reverse.each {|hist|
      Readline::HISTORY.push(hist)
    }
  end
end

.push(command) ⇒ Object



21
22
23
# File 'lib/qcmd/history.rb', line 21

def push command
  Qcmd::Configuration.history.puts command
end