Class: VimSwap
- Inherits:
-
Object
- Object
- VimSwap
- Defined in:
- lib/vim-swap.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #each ⇒ Object
- #each_not_running ⇒ Object
- #each_running ⇒ Object
-
#initialize ⇒ VimSwap
constructor
A new instance of VimSwap.
Constructor Details
#initialize ⇒ VimSwap
Returns a new instance of VimSwap.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vim-swap.rb', line 47 def initialize Open3.popen3("vim -r") do |stdin, stdout, stderr| line = stderr.gets line = stderr.gets current = "" while (line = stderr.gets) && line !~ /^ +In directory.*$/ current += line.to_s end names = current.scan(/^\d+\..*$/) bodies = current.split(/^\d+\..*$/) bodies.shift @files = [] names.each_with_index do |swapname, index| @files << VimSwapFile.new(swapname, bodies[index]) end end end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
45 46 47 |
# File 'lib/vim-swap.rb', line 45 def files @files end |
Instance Method Details
#each ⇒ Object
67 68 69 70 71 |
# File 'lib/vim-swap.rb', line 67 def each @files.each do |f| yield f end end |
#each_not_running ⇒ Object
79 80 81 82 83 |
# File 'lib/vim-swap.rb', line 79 def each_not_running @files.each do |f| yield f if !f.running? end end |
#each_running ⇒ Object
73 74 75 76 77 |
# File 'lib/vim-swap.rb', line 73 def each_running @files.each do |f| yield f if f.running? end end |