Class: FFProbe::SafePipe

Inherits:
Object
  • Object
show all
Defined in:
lib/ffprobe/safe_pipe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(program, *args) ⇒ SafePipe

Returns a new instance of SafePipe.



8
9
10
11
# File 'lib/ffprobe/safe_pipe.rb', line 8

def initialize(program,*args)
  self.program = program
  self.args = args
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



6
7
8
# File 'lib/ffprobe/safe_pipe.rb', line 6

def args
  @args
end

#programObject

Returns the value of attribute program.



6
7
8
# File 'lib/ffprobe/safe_pipe.rb', line 6

def program
  @program
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/ffprobe/safe_pipe.rb', line 6

def status
  @status
end

Instance Method Details

#run(&optional_block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ffprobe/safe_pipe.rb', line 13

def run(&optional_block)
  # closing of this pipe will indicate successful exec,
  # otherwise it will stream the error
  @rexec, @wexec = IO.pipe.map {|io| set_close_on_exec(io); io }
  @reader, @writer = IO.pipe
  if @pid = fork
    parent(&optional_block)
  else
    child
  end
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/ffprobe/safe_pipe.rb', line 25

def success?
  status ? status.success? : nil
end