Sha256: 11791632ea519ee05c993c01a61145a514a5c43aba5661b59308513bafe74bec

Contents?: true

Size: 518 Bytes

Versions: 3

Compression:

Stored size: 518 Bytes

Contents

# This extension adds a UNIX-style pipe to strings
#
# Synopsis:
#
# >> puts "Flyrb is better than alfalfa" | "cowsay"
#  ____________________________________
# < Flyrb is better than alfalfa >
#  ------------------------------------
#         \   ^__^
#          \  (oo)\_______
#             (__)\       )\/\
#                 ||----w |
#                 ||     ||
# => nil
#
class String
  def |(cmd)
    IO.popen(cmd, 'r+') do |pipe|
      pipe.write(self)
      pipe.close_write
      pipe.read
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flyrb-1.0.0.c lib/flyrb/pipe.rb
flyrb-1.0.0.b lib/flyrb/pipe.rb
flyrb-1.0.0.a lib/flyrb/pipe.rb