mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8cc36df9c3
commit
fc77d9d1cb
1 changed files with 24 additions and 24 deletions
|
@ -36,27 +36,27 @@
|
||||||
# === Example 1: Using Pathname
|
# === Example 1: Using Pathname
|
||||||
#
|
#
|
||||||
# require 'pathname'
|
# require 'pathname'
|
||||||
# p = Pathname.new("/usr/bin/ruby")
|
# pn = Pathname.new("/usr/bin/ruby")
|
||||||
# size = p.size # 27662
|
# size = pn.size # 27662
|
||||||
# isdir = p.directory? # false
|
# isdir = pn.directory? # false
|
||||||
# dir = p.dirname # Pathname:/usr/bin
|
# dir = pn.dirname # Pathname:/usr/bin
|
||||||
# base = p.basename # Pathname:ruby
|
# base = pn.basename # Pathname:ruby
|
||||||
# dir, base = p.split # [Pathname:/usr/bin, Pathname:ruby]
|
# dir, base = pn.split # [Pathname:/usr/bin, Pathname:ruby]
|
||||||
# data = p.read
|
# data = pn.read
|
||||||
# p.open { |f| _ }
|
# pn.open { |f| _ }
|
||||||
# p.each_line { |line| _ }
|
# pn.each_line { |line| _ }
|
||||||
#
|
#
|
||||||
# === Example 2: Using standard Ruby
|
# === Example 2: Using standard Ruby
|
||||||
#
|
#
|
||||||
# p = "/usr/bin/ruby"
|
# pn = "/usr/bin/ruby"
|
||||||
# size = File.size(p) # 27662
|
# size = File.size(pn) # 27662
|
||||||
# isdir = File.directory?(p) # false
|
# isdir = File.directory?(pn) # false
|
||||||
# dir = File.dirname(p) # "/usr/bin"
|
# dir = File.dirname(pn) # "/usr/bin"
|
||||||
# base = File.basename(p) # "ruby"
|
# base = File.basename(pn) # "ruby"
|
||||||
# dir, base = File.split(p) # ["/usr/bin", "ruby"]
|
# dir, base = File.split(pn) # ["/usr/bin", "ruby"]
|
||||||
# data = File.read(p)
|
# data = File.read(pn)
|
||||||
# File.open(p) { |f| _ }
|
# File.open(pn) { |f| _ }
|
||||||
# File.foreach(p) { |line| _ }
|
# File.foreach(pn) { |line| _ }
|
||||||
#
|
#
|
||||||
# === Example 3: Special features
|
# === Example 3: Special features
|
||||||
#
|
#
|
||||||
|
@ -690,12 +690,12 @@ class Pathname
|
||||||
# filename only.
|
# filename only.
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
# p = Pathname("/usr/lib/ruby/1.8")
|
# pn = Pathname("/usr/lib/ruby/1.8")
|
||||||
# p.children
|
# pn.children
|
||||||
# # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
|
# # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
|
||||||
# Pathname:/usr/lib/ruby/1.8/Env.rb,
|
# Pathname:/usr/lib/ruby/1.8/Env.rb,
|
||||||
# Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
|
# Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
|
||||||
# p.children(false)
|
# pn.children(false)
|
||||||
# # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
|
# # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
|
||||||
#
|
#
|
||||||
# Note that the result never contain the entries <tt>.</tt> and <tt>..</tt> in
|
# Note that the result never contain the entries <tt>.</tt> and <tt>..</tt> in
|
||||||
|
@ -997,7 +997,7 @@ end
|
||||||
|
|
||||||
class Pathname # * Dir *
|
class Pathname # * Dir *
|
||||||
# See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
|
# See <tt>Dir.glob</tt>. Returns or yields Pathname objects.
|
||||||
def Pathname.glob(*args) # :yield: p
|
def Pathname.glob(*args) # :yield: pathname
|
||||||
if block_given?
|
if block_given?
|
||||||
Dir.glob(*args) {|f| yield self.new(f) }
|
Dir.glob(*args) {|f| yield self.new(f) }
|
||||||
else
|
else
|
||||||
|
@ -1029,7 +1029,7 @@ class Pathname # * Dir *
|
||||||
# yields a Pathname object for each entry.
|
# yields a Pathname object for each entry.
|
||||||
#
|
#
|
||||||
# This method has existed since 1.8.1.
|
# This method has existed since 1.8.1.
|
||||||
def each_entry(&block) # :yield: p
|
def each_entry(&block) # :yield: pathname
|
||||||
Dir.foreach(@path) {|f| yield self.class.new(f) }
|
Dir.foreach(@path) {|f| yield self.class.new(f) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1063,7 +1063,7 @@ class Pathname # * Find *
|
||||||
# If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
|
# If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
|
||||||
# current directory, not <tt>./</tt>.
|
# current directory, not <tt>./</tt>.
|
||||||
#
|
#
|
||||||
def find(&block) # :yield: p
|
def find(&block) # :yield: pathname
|
||||||
require 'find'
|
require 'find'
|
||||||
if @path == '.'
|
if @path == '.'
|
||||||
Find.find(@path) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
|
Find.find(@path) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
|
||||||
|
|
Loading…
Reference in a new issue