Rioでcat続き

Rioのオブジェクトを標準出力するためには,こういう風にできるみたい.

rio('afile') > rio(?-)

だから,昨日のcatはこういう風に書き直せる.

require 'rubygems'
require 'rio'

path = ARGV.shift

rio(path) > rio(?-)

同様に,headもこうなる.

require 'rubygems'
require 'rio'

path = ARGV.shift

unless h = ARGV.shift.to_i then h = 10 end

rio(path).lines(0 .. (h - 1)) > rio(?-)

短くなった気分.