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

ruby-changes:58457

From: zverok <ko1@a...>
Date: Sun, 27 Oct 2019 02:31:29 +0900 (JST)
Subject: [ruby-changes:58457] f93cb6904c (master): OptionParser: document into: argument

https://git.ruby-lang.org/ruby.git/commit/?id=f93cb6904c

From f93cb6904c69de51bf14b1bcf9fcfc483584f4d3 Mon Sep 17 00:00:00 2001
From: zverok <zverok.offline@g...>
Date: Sat, 26 Oct 2019 11:46:54 +0300
Subject: OptionParser: document into: argument


diff --git a/lib/optparse.rb b/lib/optparse.rb
index 9745e4d..b6d7170 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -169,7 +169,7 @@ https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L169
 # - Array -- Strings separated by ',' (e.g. 1,2,3)
 # - Regexp -- Regular expressions. Also includes options.
 #
-# We can also add our own coercions, which we will cover soon.
+# We can also add our own coercions, which we will cover below.
 #
 # ==== Using Built-in Conversions
 #
@@ -1548,7 +1548,10 @@ XXX https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1548
 
   #
   # Parses command line arguments +argv+ in order. When a block is given,
-  # each non-option argument is yielded.
+  # each non-option argument is yielded. When optional +into+ keyword
+  # argument is provided, the parsed option values are stored there via
+  # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
+  # similar object).
   #
   # Returns the rest of +argv+ left unparsed.
   #
@@ -1644,7 +1647,10 @@ XXX https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1647
 
   #
   # Parses command line arguments +argv+ in permutation mode and returns
-  # list of non-option arguments.
+  # list of non-option arguments. When optional +into+ keyword
+  # argument is provided, the parsed option values are stored there via
+  # <code>[]=</code> method (so it can be Hash, or OpenStruct, or other
+  # similar object).
   #
   def permute(*argv, into: nil)
     argv = argv[0].dup if argv.size == 1 and Array === argv[0]
@@ -1665,6 +1671,9 @@ XXX https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L1671
   #
   # Parses command line arguments +argv+ in order when environment variable
   # POSIXLY_CORRECT is set, and in permutation mode otherwise.
+  # When optional +into+ keyword argument is provided, the parsed option
+  # values are stored there via <code>[]=</code> method (so it can be Hash,
+  # or OpenStruct, or other similar object).
   #
   def parse(*argv, into: nil)
     argv = argv[0].dup if argv.size == 1 and Array === argv[0]
-- 
cgit v0.10.2


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

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