Ruby syntax is a little different than most programming languages. However I have found that it is worth the time and effort required in learning the style. Here is an easy way to use Ruby and Linux Bash shell seamlessly through redirection, giving a world of capabilities, simply:
$ echo 'stuff' | ruby -e 'puts "this -> #{ARGF.read.chomp} <- is it."'
this -> stuff <- is it.
$
Here we see the ARGF constant is assigned data from the left hand side as a String:
$ echo 'stuff' | ruby -e 'puts "this -> #{ARGF.read.class} <- is it."'
this -> String <- is it.
$
That's all there is to it! Hope you've learned something, and I welcome your comments. Have a great day!
--Matt
No comments:
Post a Comment