Class: DiffRunner::Presenter

Inherits:
Object
  • Object
show all
Defined in:
lib/diff-runner/presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pidObject (readonly)

Returns the value of attribute pid.



4
5
6
# File 'lib/diff-runner/presenter.rb', line 4

def pid
  @pid
end

Instance Method Details

#present(str) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/diff-runner/presenter.rb', line 6

def present(str)
	presenting = true
	if @pid
		Process.kill("QUIT", @pid) rescue nil
	end

	Thread.new do
		puts `clear`
		IO.popen("less", "w") do |io|
			io.puts str	
			@pid = io.pid
		end

		if !presenting
			puts `clear`
			exit(0)
		end
	end

	presenting = false
end