Class: Intar::RedirectPipe

Inherits:
Redirect show all
Defined in:
lib/intar/redirect.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Redirect

#redirect_output

Constructor Details

#initialize(pager) ⇒ RedirectPipe

Returns a new instance of RedirectPipe.



40
41
42
# File 'lib/intar/redirect.rb', line 40

def initialize pager
  @pager = pager||ENV[ "PAGER"]||"more"
end

Class Method Details

.detect(line, pager) ⇒ Object



34
35
36
37
38
# File 'lib/intar/redirect.rb', line 34

def detect line, pager
  if line.slice! /\s+\|((?:\b|\/)[^|&;{}()\[\]]*)?\z/ then
    new $1||pager
  end
end

Instance Method Details

#outfileObject



43
44
45
46
47
# File 'lib/intar/redirect.rb', line 43

def outfile
  IO.popen @pager.to_s, "w"
rescue Errno::ENOENT
  raise Failed, "Pipe error: #$!"
end