lib/rio/doc/HOWTO.rb in rio-0.3.7 vs lib/rio/doc/HOWTO.rb in rio-0.3.8
- old
+ new
@@ -1,8 +1,8 @@
#--
# ===============================================================================
-# Copyright (c) 2005, Christopher Kleckner
+# Copyright (c) 2005, 2006 Christopher Kleckner
# All rights reserved
#
# This file is part of the Rio library for ruby.
#
# Rio is free software; you can redistribute it and/or modify
@@ -20,11 +20,11 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ===============================================================================
#++
#
# To create the documentation for Rio run the command
-# rake rdoc
+# ruby build_doc.rb
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
#
# Suggested Reading
# * RIO::Doc::SYNOPSIS
# * RIO::Doc::INTRO
@@ -267,43 +267,54 @@
* Put all entries with the extension '.txt' into an array
# method 1
array = ario['*.txt']
# method 2
- array = ario[/\.txt/]
+ array = ario[/\.txt$/]
# method 3
array = ario.entries['*.txt']
* Put all files with the extension '.txt' into an array
# method 1
array = ario.files['*.txt']
# method 2
- array = ario.files[/\.txt/]
+ array = ario.files[/\.txt$/]
# method 3
array = ario.files['*.txt']
* Put all entries with the extension '.txt' into an array, including those in subdirectories
# method 1
array = ario.all['*.txt']
# method 2
- array = ario.all[/\.txt/]
+ array = ario.all[/\.txt$/]
# method 3
array = ario.all.entries['*.txt']
* Put all entries with the extension '.txt' into an array, including those in subdirectories, except those
in subdirectories name '.svn'
# method 1
array = ario.norecurse('.svn').all['*.txt']
# method 2
- array = ario.norecurse(/^\.svn$/).all[/\.txt/]
+ array = ario.norecurse(/^\.svn$/).all[/\.txt$/]
# method 3
array = ario.norecurse('.svn').entries['*.txt']
# method 4
array = ario.entries('*.txt').norecurse('.svn').to_a
# method 5
array = ario.norecurse('.svn')['*.txt']
+* Put all directories (recursively) into an array
+ # method 1
+ array = ario.dirs[]
+ # method 2
+ array = ario.dirs.to_a
+
+* Put all entries (recursively) into an array, but limit the depth of recursion to 2
+ # method 1
+ array = ario.norecurse(3).to_a
+
+
* Iterate through ruby files in a directory and subdirectories skipping
those in the '.svn', and 'pkg' directories
# method 1
is_ruby_exe = proc{ |f| f.executable? and f[0][0] =~ /^#!.+ruby/ }
ario.norecurse('.svn','pkg').files('*.rb',is_ruby_exe) { |f| ... }
@@ -335,11 +346,11 @@
* Put all directories except those named '.svn' into an array
# method 1
array = ario.skipdirs['.svn']
# method 2
- array = ario.skipdirs[/^\.svn/]
+ array = ario.skipdirs[/^\.svn$/]
# method 3
array = ario.skipdirs('.svn').to_a
# method 4
array = ario.skipdirs('.svn').dirs[]
# method 5
@@ -646,9 +657,14 @@
end
# method 2
rio('adir').all.files('*.htm') do |htmfile|
htmfile.rename.extname = '.html'
end
+
+* Move a file in an arbitrary directory into the current working directory.
+ # method 1
+ rio('arb/i/trary/di/rec/tory/afile').rename.dirname = '.'
+
---
=== Manipulate a Rio's path
string = ""