Class: VimSwap

Inherits:
Object
  • Object
show all
Defined in:
lib/vim-swap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVimSwap

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

#filesObject (readonly)

Returns the value of attribute files.



45
46
47
# File 'lib/vim-swap.rb', line 45

def files
  @files
end

Instance Method Details

#eachObject



67
68
69
70
71
# File 'lib/vim-swap.rb', line 67

def each
	@files.each do |f|
		yield f
	end
end

#each_not_runningObject



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_runningObject



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