Class: F0cus
- Inherits:
-
Object
- Object
- F0cus
- Defined in:
- lib/f0cus.rb
Constant Summary collapse
- FILE =
File.join(Dir.home, '.f0cus')
Class Method Summary collapse
Class Method Details
.run(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/f0cus.rb', line 6 def self.run(args) subcommand = args.shift case subcommand when 'push' str = args.shift File.open(FILE, 'a') { |file| file.write("#{str}\n") } puts str exit when 'pop' lines = File.readlines(FILE) lines.pop File.open(FILE, 'w') do |f| lines.each do |line| f.write(line) end end puts lines.last else FileUtils.touch(FILE) puts File.readlines(FILE).last end end |