Sha256: e215c04bc32a4e703a08196e5582c00c330eaab591d7af905231402bb0808b8b

Contents?: true

Size: 530 Bytes

Versions: 13

Compression:

Stored size: 530 Bytes

Contents

# This extension adds a UNIX-style pipe to strings
#
# Synopsis:
#
# >> puts "UtilityBelt is better than alfalfa" | "cowsay"
#  ____________________________________
# < UtilityBelt 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

13 entries across 13 versions & 6 rubygems

Version Path
FreedomCoder-utility_belt-1.1.1.2 lib/utility_belt/pipe.rb
FreedomCoder-utility_belt-1.1.1 lib/utility_belt/pipe.rb
akitaonrails-utility_belt-1.0.10 lib/utility_belt/pipe.rb
akitaonrails-utility_belt-1.0.11 lib/utility_belt/pipe.rb
akitaonrails-utility_belt-1.0.12 lib/utility_belt/pipe.rb
mguterl-utility_belt-1.0.7 lib/utility_belt/pipe.rb
rwilcox-utility_belt-1.0.7 lib/utility_belt/pipe.rb
rwilcox-utility_belt-1.0.9 lib/utility_belt/pipe.rb
timocratic-utility_belt-1.0.7.1 lib/utility_belt/pipe.rb
timocratic-utility_belt-1.0.7.2 lib/utility_belt/pipe.rb
timocratic-utility_belt-1.0.7.3 lib/utility_belt/pipe.rb
akitaonrails-utility_belt-1.0.13 lib/utility_belt/pipe.rb
utility_belt-1.1.0 lib/utility_belt/pipe.rb