Class: Functional::Pager
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #call_inspect(*a) ⇒ Object
- #clean ⇒ Object
- #end ⇒ Object
-
#initialize(*opts) ⇒ Pager
constructor
A new instance of Pager.
- #pager_fun(*a) ⇒ Object (also: #call)
Methods inherited from Base
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 |
#clean ⇒ Object
325 326 327 |
# File 'lib/functional.rb', line 325 def clean @pager.close end |
#end ⇒ Object
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 |