[前][次][番号順一覧][スレッド一覧]

ruby-changes:32339

From: zzak <ko1@a...>
Date: Wed, 25 Dec 2013 22:34:34 +0900 (JST)
Subject: [ruby-changes:32339] zzak:r44418 (trunk): * lib/abbrev.rb: [DOC] rdoc format patch by Giorgos Tsiftsis [Bug #9146]

zzak	2013-12-25 22:34:27 +0900 (Wed, 25 Dec 2013)

  New Revision: 44418

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44418

  Log:
    * lib/abbrev.rb: [DOC] rdoc format patch by Giorgos Tsiftsis [Bug #9146]

  Modified files:
    trunk/ChangeLog
    trunk/lib/abbrev.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44417)
+++ ChangeLog	(revision 44418)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec 25 22:32:19 2013  Zachary Scott  <e@z...>
+
+	* lib/abbrev.rb: [DOC] rdoc format patch by Giorgos Tsiftsis [Bug #9146]
+
 Wed Dec 25 20:30:10 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* iseq.c (rb_iseq_parameters): push argument type symbol only for
Index: lib/abbrev.rb
===================================================================
--- lib/abbrev.rb	(revision 44417)
+++ lib/abbrev.rb	(revision 44418)
@@ -11,43 +11,46 @@ https://github.com/ruby/ruby/blob/trunk/lib/abbrev.rb#L11
 #++
 
 ##
-# Calculates the set of unique abbreviations for a given set of strings.
+# Calculates the set of unambiguous abbreviations for a given set of strings.
 #
 #   require 'abbrev'
 #   require 'pp'
 #
-#   pp Abbrev.abbrev(['ruby', 'rules'])
+#   pp Abbrev.abbrev(['ruby'])
+#   #=>  {"ruby"=>"ruby", "rub"=>"ruby", "ru"=>"ruby", "r"=>"ruby"}
 #
-# Generates:
+#   pp Abbrev.abbrev(%w{ ruby rules })
 #
-#   { "rub"   =>  "ruby",
-#     "ruby"  =>  "ruby",
-#     "rul"   =>  "rules",
+# _Generates:_
+#   { "ruby"  =>  "ruby",
+#     "rub"   =>  "ruby",
+#     "rules" =>  "rules",
 #     "rule"  =>  "rules",
-#     "rules" =>  "rules" }
+#     "rul"   =>  "rules" }
 #
 # It also provides an array core extension, Array#abbrev.
 #
-#   pp %w{summer winter}.abbrev
-#   #=> {"summe"=>"summer",
-#        "summ"=>"summer",
-#        "sum"=>"summer",
-#        "su"=>"summer",
-#        "s"=>"summer",
-#        "winte"=>"winter",
-#        "wint"=>"winter",
-#        "win"=>"winter",
-#        "wi"=>"winter",
-#        "w"=>"winter",
-#        "summer"=>"summer",
-#        "winter"=>"winter"}
+#   pp %w{ summer winter }.abbrev
+#
+# _Generates:_
+#   { "summer"  => "summer",
+#     "summe"   => "summer",
+#     "summ"    => "summer",
+#     "sum"     => "summer",
+#     "su"      => "summer",
+#     "s"       => "summer",
+#     "winter"  => "winter",
+#     "winte"   => "winter",
+#     "wint"    => "winter",
+#     "win"     => "winter",
+#     "wi"      => "winter",
+#     "w"       => "winter" }
 
 module Abbrev
 
-  # Given a set of strings, calculate the set of unambiguous
-  # abbreviations for those strings, and return a hash where the keys
-  # are all the possible abbreviations and the values are the full
-  # strings.
+  # Given a set of strings, calculate the set of unambiguous abbreviations for
+  # those strings, and return a hash where the keys are all the possible
+  # abbreviations and the values are the full strings.
   #
   # Thus, given +words+ is "car" and "cone", the keys pointing to "car" would
   # be "ca" and "car", while those pointing to "cone" would be "co", "con", and
@@ -55,15 +58,18 @@ module Abbrev https://github.com/ruby/ruby/blob/trunk/lib/abbrev.rb#L58
   #
   #   require 'abbrev'
   #
-  #   Abbrev.abbrev(['car', 'cone'])
+  #   Abbrev.abbrev(%w{ car cone })
   #   #=> {"ca"=>"car", "con"=>"cone", "co"=>"cone", "car"=>"car", "cone"=>"cone"}
   #
-  # The optional +pattern+ parameter is a pattern or a string. Only
-  # input strings that match the pattern or start with the string
-  # are included in the output hash.
+  # The optional +pattern+ parameter is a pattern or a string. Only input
+  # strings that match the pattern or start with the string are included in the
+  # output hash.
+  #
+  #   Abbrev.abbrev(%w{car box cone crab}, /b/)
+  #   #=> {"box"=>"box", "bo"=>"box", "b"=>"box", "crab" => "crab"}
   #
-  #   Abbrev.abbrev(%w{car box cone}, /b/)
-  #   #=> {"bo"=>"box", "b"=>"box", "box"=>"box"}
+  #   Abbrev.abbrev(%w{car box cone}, 'ca')
+  #   #=> {"car"=>"car", "ca"=>"car"}
   def abbrev(words, pattern = nil)
     table = {}
     seen = Hash.new(0)
@@ -103,21 +109,21 @@ module Abbrev https://github.com/ruby/ruby/blob/trunk/lib/abbrev.rb#L109
 end
 
 class Array
-  # Calculates the set of unambiguous abbreviations for the strings in
-  # +self+.
+  # Calculates the set of unambiguous abbreviations for the strings in +self+.
   #
   #   require 'abbrev'
   #   %w{ car cone }.abbrev
-  #   #=> {"ca" => "car", "con"=>"cone", "co" => "cone",
-  #        "car"=>"car", "cone" => "cone"}
+  #   #=> {"car"=>"car", "ca"=>"car", "cone"=>"cone", "con"=>"cone", "co"=>"cone"}
   #
-  # The optional +pattern+ parameter is a pattern or a string. Only
-  # input strings that match the pattern or start with the string
-  # are included in the output hash.
+  # The optional +pattern+ parameter is a pattern or a string. Only input
+  # strings that match the pattern or start with the string are included in the
+  # output hash.
   #
   #   %w{ fast boat day }.abbrev(/^.a/)
-  #   #=> {"fas"=>"fast", "fa"=>"fast", "da"=>"day",
-  #        "fast"=>"fast", "day"=>"day"}
+  #   #=> {"fast"=>"fast", "fas"=>"fast", "fa"=>"fast", "day"=>"day", "da"=>"day"}
+  #
+  #   Abbrev.abbrev(%w{car box cone}, "ca")
+  #   #=> {"car"=>"car", "ca"=>"car"}
   #
   # See also Abbrev.abbrev
   def abbrev(pattern = nil)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]