Sha256: 937b47f9e808b694f6f7f03da114fa9c118725141854d2afb0d1d389f71bf3f1

Contents?: true

Size: 806 Bytes

Versions: 1

Compression:

Stored size: 806 Bytes

Contents

# encoding: utf-8
# (c) 2010 - 2011 Martin Kozák (martinkozak@martinkozak.net)

##
# Pipe class of the +pipe-run+. Currently with one static method only.
#

class Pipe

    ##
    # Runs the command and returns its standard output.
    #
    # If block is given, treat call as non-blocking. In that case, 
    # +em-pipe-run+ file must be loaded.
    #
    # @param [String] command command for run
    # @param [Proc] block block for giving back the results
    # @return [String] command output
    #

    def self.run(command, &block)
        if not block.nil?
            return self.run_nonblock(command, &block)
        end
        
        ###
        
        pipe = File.popen(command, "r")
        
        result = pipe.read
        pipe.close()
        
        return result
    end
    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipe-run-0.2.0 lib/pipe-run.rb