ruby-changes:25636
From: eregon <ko1@a...>
Date: Sat, 17 Nov 2012 08:20:13 +0900 (JST)
Subject: [ruby-changes:25636] eregon:r37693 (trunk): * lib/abbrev.rb: fix r37113. Correct examples, fix style
eregon 2012-11-17 08:14:38 +0900 (Sat, 17 Nov 2012) New Revision: 37693 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37693 Log: * lib/abbrev.rb: fix r37113. Correct examples, fix style and show explicit dependency (require 'abbrev'). Modified files: trunk/ChangeLog trunk/lib/abbrev.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 37692) +++ ChangeLog (revision 37693) @@ -1,3 +1,8 @@ +Sat Nov 17 08:13:48 2012 Benoit Daloze <eregontp@g...> + + * lib/abbrev.rb: fix r37113. Correct examples, fix style + and show explicit dependency (require 'abbrev'). + Sat Nov 17 07:35:15 2012 Luis Lavena <luislavena@g...> * win32/file.c (replace_to_long_name): skip automatic path expansion Index: lib/abbrev.rb =================================================================== --- lib/abbrev.rb (revision 37692) +++ lib/abbrev.rb (revision 37693) @@ -28,7 +28,7 @@ # # It also provides an array core extension, Array#abbrev. # -# pp %w{april may}.abbrev +# pp %w{summer winter}.abbrev # #=> {"summe"=>"summer", # "summ"=>"summer", # "sum"=>"summer", @@ -54,16 +54,15 @@ # "cone". # # require 'abbrev' - # require 'pp' # - # pp Abbrev.abbrev(['car', 'cone']) + # Abbrev.abbrev(['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. # - # pp %w{car box cone}.abbrev(/b/) + # Abbrev.abbrev(%w{car box cone}, /b/) # #=> {"bo"=>"box", "b"=>"box", "box"=>"box"} def abbrev(words, pattern = nil) table = {} @@ -107,18 +106,18 @@ # Calculates the set of unambiguous abbreviations for the strings in # +self+. # - # abbr = %w{ car cone }.abbrev - # abbr #=> { "ca" => "car", "car" => "car", - # "co" => "cone", "con" => "cone", - # "cone" => "cone" } + # require 'abbrev' + # %w{ car cone }.abbrev + # #=> {"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. # - # abbr = %w{ fast boat day }.abbrev(/^.a.*$/) - # abbr #=> {"fas"=>"fast","fa"=>"fast", - # "da"=>"day", "fast"=>"fast", "day"=>"day"} + # %w{ fast boat day }.abbrev(/^.a/) + # #=> {"fas"=>"fast", "fa"=>"fast", "da"=>"day", + # "fast"=>"fast", "day"=>"day"} # # See also Abbrev.abbrev def abbrev(pattern = nil) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/