Skip to content

Commit f1c79cc

Browse files
authored
Put private before method declarations
1 parent ff6a342 commit f1c79cc

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

lib/optparse.rb

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ def initialize(pattern = nil, conv = nil,
562562
# Parses +arg+ and returns rest of +arg+ and matched portion to the
563563
# argument pattern. Yields when the pattern doesn't match substring.
564564
#
565-
def parse_arg(arg) # :nodoc:
565+
private def parse_arg(arg) # :nodoc:
566566
pattern or return nil, [arg]
567567
unless m = pattern.match(arg)
568568
yield(InvalidArgument, arg)
@@ -580,14 +580,13 @@ def parse_arg(arg) # :nodoc:
580580
yield(InvalidArgument, arg) # didn't match whole arg
581581
return arg[s.length..-1], m
582582
end
583-
private :parse_arg
584583

585584
#
586585
# Parses argument, converts and returns +arg+, +block+ and result of
587586
# conversion. Yields at semi-error condition instead of raising an
588587
# exception.
589588
#
590-
def conv_arg(arg, val = []) # :nodoc:
589+
private def conv_arg(arg, val = []) # :nodoc:
591590
v, = *val
592591
if conv
593592
val = conv.call(*val)
@@ -599,7 +598,6 @@ def conv_arg(arg, val = []) # :nodoc:
599598
end
600599
return arg, block, val
601600
end
602-
private :conv_arg
603601

604602
#
605603
# Produces the summary text. Each line of the summary is yielded to the
@@ -883,14 +881,13 @@ def reject(t)
883881
# +lopts+:: Long style option list.
884882
# +nlopts+:: Negated long style options list.
885883
#
886-
def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
884+
private def update(sw, sopts, lopts, nsw = nil, nlopts = nil) # :nodoc:
887885
sopts.each {|o| @short[o] = sw} if sopts
888886
lopts.each {|o| @long[o] = sw} if lopts
889887
nlopts.each {|o| @long[o] = nsw} if nsw and nlopts
890888
used = @short.invert.update(@long.invert)
891889
@list.delete_if {|o| Switch === o and !used[o]}
892890
end
893-
private :update
894891

895892
#
896893
# Inserts +switch+ at the head of the list, and associates short, long
@@ -1459,14 +1456,13 @@ def to_a; summarize("#{banner}".split(/^/)) end
14591456
# +prv+:: Previously specified argument.
14601457
# +msg+:: Exception message.
14611458
#
1462-
def notwice(obj, prv, msg) # :nodoc:
1459+
private def notwice(obj, prv, msg) # :nodoc:
14631460
unless !prv or prv == obj
14641461
raise(ArgumentError, "argument #{msg} given twice: #{obj}",
14651462
ParseError.filter_backtrace(caller(2)))
14661463
end
14671464
obj
14681465
end
1469-
private :notwice
14701466

14711467
SPLAT_PROC = proc {|*a| a.length <= 1 ? a.first : a} # :nodoc:
14721468

@@ -1733,7 +1729,7 @@ def order!(argv = default_argv, into: nil, **keywords, &nonopt)
17331729
parse_in_order(argv, setter, **keywords, &nonopt)
17341730
end
17351731

1736-
def parse_in_order(argv = default_argv, setter = nil, exact: require_exact, **, &nonopt) # :nodoc:
1732+
private def parse_in_order(argv = default_argv, setter = nil, exact: require_exact, **, &nonopt) # :nodoc:
17371733
opt, arg, val, rest = nil
17381734
nonopt ||= proc {|a| throw :terminate, a}
17391735
argv.unshift(arg) if arg = catch(:terminate) {
@@ -1824,10 +1820,9 @@ def parse_in_order(argv = default_argv, setter = nil, exact: require_exact, **,
18241820

18251821
argv
18261822
end
1827-
private :parse_in_order
18281823

18291824
# Calls callback with _val_.
1830-
def callback!(cb, max_arity, *args) # :nodoc:
1825+
private def callback!(cb, max_arity, *args) # :nodoc:
18311826
args.compact!
18321827

18331828
if (size = args.size) < max_arity and cb.to_proc.lambda?
@@ -1837,7 +1832,6 @@ def callback!(cb, max_arity, *args) # :nodoc:
18371832
end
18381833
cb.call(*args)
18391834
end
1840-
private :callback!
18411835

18421836
#
18431837
# Parses command line arguments +argv+ in permutation mode and returns
@@ -1951,24 +1945,22 @@ def self.getopts(*args, symbolize_names: false)
19511945
# Traverses @stack, sending each element method +id+ with +args+ and
19521946
# +block+.
19531947
#
1954-
def visit(id, *args, &block) # :nodoc:
1948+
private def visit(id, *args, &block) # :nodoc:
19551949
@stack.reverse_each do |el|
19561950
el.__send__(id, *args, &block)
19571951
end
19581952
nil
19591953
end
1960-
private :visit
19611954

19621955
#
19631956
# Searches +key+ in @stack for +id+ hash and returns or yields the result.
19641957
#
1965-
def search(id, key) # :nodoc:
1958+
private def search(id, key) # :nodoc:
19661959
block_given = block_given?
19671960
visit(:search, id, key) do |k|
19681961
return block_given ? yield(k) : k
19691962
end
19701963
end
1971-
private :search
19721964

19731965
#
19741966
# Completes shortened long style option switch and returns pair of
@@ -1979,7 +1971,7 @@ def search(id, key) # :nodoc:
19791971
# +icase+:: Search case insensitive if true.
19801972
# +pat+:: Optional pattern for completion.
19811973
#
1982-
def complete(typ, opt, icase = false, *pat) # :nodoc:
1974+
private def complete(typ, opt, icase = false, *pat) # :nodoc:
19831975
if pat.empty?
19841976
search(typ, opt) {|sw| return [sw, opt]} # exact match or...
19851977
end
@@ -1989,7 +1981,6 @@ def complete(typ, opt, icase = false, *pat) # :nodoc:
19891981
exc = ambiguous ? AmbiguousOption : InvalidOption
19901982
raise exc.new(opt, additional: proc {|o| additional_message(typ, o)})
19911983
end
1992-
private :complete
19931984

19941985
#
19951986
# Returns additional info.

0 commit comments

Comments
 (0)