lib/rio/doc/HOWTO.rb in rio-0.3.1 vs lib/rio/doc/HOWTO.rb in rio-0.3.2
- old
+ new
@@ -101,11 +101,11 @@
# method 2
ario.chomp.lines(0...10) >> array
* Read all lines starting with 'require' into an array, with each line chomped
# method 1
- array = ario.chomp.lines(/^\s*require/)
+ array = ario.chomp.lines[/^\s*require/]
# method 2
ario.chomp.lines(/^\s*require/) > array
* Read a gzipped file into a string
# method 1
@@ -171,11 +171,11 @@
# method 1
ario.puts(string)
# method 2
ario.print(string)
# method 3
- ario.noclose < string
+ ario.noautoclose < string
* Write a string to a file and close the file
# method 1
rio('afile') < string
# method 2
@@ -187,11 +187,11 @@
# method 1
ario.a.puts(string)
# method 2
ario.a.print(string)
# method 3
- ario.noclose << string
+ ario.noautoclose << string
* Append a string to a file and close the file
# method 1
rio('afile') << string
# method 2
@@ -202,11 +202,11 @@
* Write an array to a file, leaving the Rio open
# method 1
ario = rio('afile').nocloseoncopy
ario << array
# method 2
- ario.noclose < array
+ ario.noautoclose < array
* Write an array to a file and close the file
# method 1
rio('afile') < array
@@ -300,12 +300,17 @@
# method 4
array = ario.entries('*.txt').norecurse('.svn').to_a
# method 5
array = ario.norecurse('.svn')['*.txt']
-* Iterate through all ruby files in a directory structure except those in the '.svn' and 'pkg' directories
+* Iterate through ruby files in a directory and subdirectories skipping
+ those in the '.svn', and 'pkg' directories
# method 1
- ario.norecurse('.svn','pkg').files('*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }) { |f| ... }
+ is_ruby_exe = proc{ |f| f.executable? and f[0][0] =~ /^#!.+ruby/ }
+ ario.norecurse('.svn','pkg').files('*.rb',is_ruby_exe) { |f| ... }
+ # method 2
+ is_ruby_exe = proc{ |f| f.executable? and f.gets =~ /^#!.+ruby/ }
+ ario.norecurse('.svn','pkg').files('*.rb',is_ruby_exe) { |f| ... }
* Put all files excluding those that are symlinks to files in an array
# method 1
array = ario.nofiles[:symlink?]
# method 2