Class: Functional::Pager

Inherits:
Base show all
Defined in:
lib/functional.rb

Instance Attribute Summary

Attributes inherited from Base

#caller, #exe, #next

Instance Method Summary collapse

Methods inherited from Base

#base_fun, #to_proc

Constructor Details

#initialize(*opts) ⇒ Pager

Returns a new instance of Pager.



306
307
308
309
310
311
312
313
314
# File 'lib/functional.rb', line 306

def initialize *opts
	@pager = IO.popen ENV['PAGER'] || 'less', 'w'
	opts.each do |opt|
		case opt.to_s
		when *%w[inspect i] then alias call call_inspect
		else raise ArgumentError, "Unknown opt: #{opt}"
		end
	end
end

Instance Method Details

#call_inspect(*a) ⇒ Object



316
317
318
# File 'lib/functional.rb', line 316

def call_inspect *a
	@pager.puts a.inspect
end

#cleanObject



325
326
327
# File 'lib/functional.rb', line 325

def clean
	@pager.close
end

#endObject



329
330
331
332
# File 'lib/functional.rb', line 329

def end
	clean
	nil
end

#pager_fun(*a) ⇒ Object Also known as: call



320
321
322
# File 'lib/functional.rb', line 320

def pager_fun *a
	@pager.puts a
end