libpath-ruby 0.2.2.1 → 0.2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/libpath/constants/unix.rb +66 -66
- data/lib/libpath/constants/windows.rb +67 -67
- data/lib/libpath/constants.rb +3 -2
- data/lib/libpath/diagnostics/parameter_checking.rb +2 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +12 -13
- data/lib/libpath/exceptions/malformed_name_exception.rb +21 -22
- data/lib/libpath/form/unix.rb +110 -111
- data/lib/libpath/form/windows.rb +208 -195
- data/lib/libpath/form.rb +2 -3
- data/lib/libpath/internal_/array.rb +48 -48
- data/lib/libpath/internal_/platform.rb +26 -27
- data/lib/libpath/internal_/string.rb +22 -17
- data/lib/libpath/internal_/unix/form.rb +118 -113
- data/lib/libpath/internal_/windows/drive.rb +76 -71
- data/lib/libpath/internal_/windows/form.rb +206 -195
- data/lib/libpath/libpath.rb +1 -1
- data/lib/libpath/path/unix.rb +106 -106
- data/lib/libpath/path/windows.rb +101 -101
- data/lib/libpath/path.rb +3 -1
- data/lib/libpath/util/unix.rb +7 -7
- data/lib/libpath/util/windows.rb +7 -7
- data/lib/libpath/util.rb +3 -2
- data/lib/libpath/version.rb +9 -9
- data/test/performance/benchmark_rindex2.rb +7 -7
- data/test/unit/exceptions/tc_malformed_name_exception.rb +2 -2
- data/test/unit/path/tc_path.rb +0 -2
- metadata +2 -2
data/lib/libpath/form/windows.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Purpose: LibPath::Form::Windows module
|
6
6
|
#
|
7
7
|
# Created: 8th January 2019
|
8
|
-
# Updated:
|
8
|
+
# Updated: 13th April 2024
|
9
9
|
#
|
10
10
|
# Home: http://github.com/synesissoftware/libpath.Ruby
|
11
11
|
#
|
@@ -45,310 +45,323 @@
|
|
45
45
|
# ######################################################################## #
|
46
46
|
|
47
47
|
|
48
|
-
=begin
|
49
|
-
=end
|
50
|
-
|
51
48
|
require 'libpath/constants/windows'
|
52
49
|
require 'libpath/diagnostics'
|
53
50
|
require 'libpath/internal_/windows/drive'
|
54
51
|
require 'libpath/internal_/windows/form'
|
55
52
|
|
56
53
|
|
57
|
-
|
58
|
-
|
59
|
-
module Windows # :nodoc:
|
54
|
+
=begin
|
55
|
+
=end
|
60
56
|
|
61
|
-
|
62
|
-
|
63
|
-
module
|
57
|
+
module LibPath
|
58
|
+
module Form
|
59
|
+
module Windows
|
64
60
|
|
65
|
-
#
|
66
|
-
#
|
67
|
-
|
68
|
-
#
|
69
|
-
# One of +:absolute+, +:drived+, +:homed+, +:relative+, +:rooted+, for
|
70
|
-
# any paths that match precisely those classifications, or +nil+ if the
|
71
|
-
# path is empty
|
72
|
-
def classify_path path
|
61
|
+
# Module defining instance functions that will be included and extended into
|
62
|
+
# any class or module including/extending module LibPath::Form::Windows
|
63
|
+
module LibPath_Form_Windows_Methods
|
73
64
|
|
74
|
-
|
65
|
+
# Classifies a path
|
66
|
+
#
|
67
|
+
# === Return
|
68
|
+
#
|
69
|
+
# One of +:absolute+, +:drived+, +:homed+, +:relative+, +:rooted+, for
|
70
|
+
# any paths that match precisely those classifications, or +nil+ if the
|
71
|
+
# path is empty
|
72
|
+
def classify_path path
|
75
73
|
|
76
|
-
|
74
|
+
_Form = Internal_::Windows::Form
|
77
75
|
|
78
|
-
|
76
|
+
Diagnostics.check_string_parameter(path, "path") if $DEBUG
|
79
77
|
|
80
|
-
|
78
|
+
return nil if path.nil? || path.empty?
|
81
79
|
|
82
|
-
|
80
|
+
return :homed if path_is_homed? path
|
83
81
|
|
84
|
-
|
82
|
+
vol, rem, _ = _Form.get_windows_volume(path)
|
85
83
|
|
86
|
-
|
84
|
+
rooted = _Form.char_is_path_name_separator? rem[0]
|
87
85
|
|
88
|
-
|
89
|
-
else
|
86
|
+
if rooted
|
90
87
|
|
91
|
-
|
92
|
-
end
|
93
|
-
else
|
88
|
+
if vol
|
94
89
|
|
95
|
-
|
90
|
+
return :absolute
|
91
|
+
else
|
96
92
|
|
97
|
-
|
93
|
+
return :rooted
|
94
|
+
end
|
98
95
|
else
|
99
96
|
|
100
|
-
|
97
|
+
if vol
|
98
|
+
|
99
|
+
return :drived
|
100
|
+
else
|
101
|
+
|
102
|
+
return :relative
|
103
|
+
end
|
101
104
|
end
|
105
|
+
|
102
106
|
end
|
103
107
|
|
104
|
-
|
108
|
+
# Evaluates whether the given name is malformed, according to the given
|
109
|
+
# options.
|
110
|
+
#
|
111
|
+
# If no options are specified, the only invalid character(s) are: +'\0'+
|
112
|
+
#
|
113
|
+
# === Signature
|
114
|
+
#
|
115
|
+
# * *Options:*
|
116
|
+
# - +:reject_path_name_separators+:: (boolean) Reject the path
|
117
|
+
# separator character(s): +'\\'+ and +'/'+
|
118
|
+
# - +:reject_path_separators+:: (boolean) Reject the path separator
|
119
|
+
# character(s): +';'+
|
120
|
+
# - +:reject_shell_characters+:: (boolean) Reject the shell
|
121
|
+
# character(s): +'*'+, +'?'+, +'|'+
|
122
|
+
def name_is_malformed? name, **options
|
123
|
+
|
124
|
+
_Constants = ::LibPath::Constants::Windows
|
125
|
+
|
126
|
+
if name
|
127
|
+
|
128
|
+
if options[:reject_shell_characters]
|
129
|
+
|
130
|
+
return true if name =~ _Constants::InvalidCharacters::Shell::RE
|
131
|
+
end
|
105
132
|
|
106
|
-
|
107
|
-
# options.
|
108
|
-
#
|
109
|
-
# If no options are specified, the only invalid character(s) are: +'\0'+
|
110
|
-
#
|
111
|
-
# === Signature
|
112
|
-
#
|
113
|
-
# * *Options:*
|
114
|
-
# - +:reject_path_name_separators+:: (boolean) Reject the path
|
115
|
-
# separator character(s): +'\\'+ and +'/'+
|
116
|
-
# - +:reject_path_separators+:: (boolean) Reject the path separator
|
117
|
-
# character(s): +';'+
|
118
|
-
# - +:reject_shell_characters+:: (boolean) Reject the shell
|
119
|
-
# character(s): +'*'+, +'?'+, +'|'+
|
120
|
-
def name_is_malformed? name, **options
|
121
|
-
|
122
|
-
_Constants = ::LibPath::Constants::Windows
|
123
|
-
|
124
|
-
if name
|
125
|
-
|
126
|
-
if options[:reject_shell_characters]
|
127
|
-
|
128
|
-
return true if name =~ _Constants::InvalidCharacters::Shell::RE
|
129
|
-
end
|
133
|
+
if options[:reject_path_separators]
|
130
134
|
|
131
|
-
|
135
|
+
return true if name =~ _Constants::InvalidCharacters::PathSeparators::RE
|
136
|
+
end
|
132
137
|
|
133
|
-
|
134
|
-
end
|
138
|
+
if options[:reject_path_name_separators]
|
135
139
|
|
136
|
-
|
140
|
+
return true if name =~ _Constants::InvalidCharacters::PathNameSeparators::RE
|
141
|
+
end
|
137
142
|
|
138
|
-
return true if name =~ _Constants::InvalidCharacters::
|
139
|
-
end
|
143
|
+
return true if name =~ _Constants::InvalidCharacters::Innate::RE
|
140
144
|
|
141
|
-
|
145
|
+
if '\\' == name[0] && '\\' == name[1]
|
142
146
|
|
143
|
-
|
147
|
+
return true if name !~ /^\\\\[^\\]+\\[^\\]+/
|
148
|
+
end
|
149
|
+
|
150
|
+
false
|
151
|
+
else
|
144
152
|
|
145
|
-
|
153
|
+
true
|
146
154
|
end
|
155
|
+
end
|
147
156
|
|
148
|
-
|
149
|
-
|
157
|
+
# Evaluates whether the given path is absolute, which means it is either
|
158
|
+
# rooted (begins with '/') or is homed (is '~' or begins with '~/')
|
159
|
+
#
|
160
|
+
# === Signature
|
161
|
+
#
|
162
|
+
# * *Parameters:*
|
163
|
+
# - +path+:: (String) The path to be evaluated. May not be +nil+
|
164
|
+
def path_is_absolute? path
|
150
165
|
|
151
|
-
|
152
|
-
end
|
153
|
-
end
|
166
|
+
_Form = Internal_::Windows::Form
|
154
167
|
|
155
|
-
|
156
|
-
# rooted (begins with '/') or is homed (is '~' or begins with '~/')
|
157
|
-
#
|
158
|
-
# === Signature
|
159
|
-
#
|
160
|
-
# * *Parameters:*
|
161
|
-
# - +path+:: (String) The path to be evaluated. May not be +nil+
|
162
|
-
def path_is_absolute? path
|
168
|
+
Diagnostics.check_string_parameter(path, "path") if $DEBUG
|
163
169
|
|
164
|
-
|
170
|
+
return true if path_is_homed? path
|
165
171
|
|
166
|
-
|
172
|
+
vol, rem, _ = _Form.get_windows_volume(path)
|
167
173
|
|
168
|
-
|
174
|
+
return false unless vol
|
175
|
+
return false unless rem
|
169
176
|
|
170
|
-
|
171
|
-
|
177
|
+
_Form.char_is_path_name_separator? rem[0]
|
178
|
+
end
|
172
179
|
|
173
|
-
|
174
|
-
|
180
|
+
# Evaluates whether the given path is "letter drived", which means that
|
181
|
+
# it contains a drive specification. Given the two letter sequence 'X:'
|
182
|
+
# representing any ASCII letter (a-zA-Z) and a colon, this function
|
183
|
+
# recognises six sequences: +'X:'+, +'X:\'+, +'X:/'+, +'\\?\X:'+,
|
184
|
+
# +'\\?\X:\'+, +'\\?\X:/'+
|
185
|
+
#
|
186
|
+
# === Return
|
187
|
+
# - +nil+:: if it is not "drived";
|
188
|
+
# - 2:: it begins with the form +'X:'+
|
189
|
+
# - 3:: it begins with the form +'X:\'+ or +'X:/'+
|
190
|
+
# - 6:: it begins with the form +'\\?\X:'+
|
191
|
+
# - 7:: it begins with the form +'\\?\X:\'+ or +'\\?\X:/'+
|
192
|
+
def path_is_letter_drived? path
|
175
193
|
|
176
|
-
|
177
|
-
|
178
|
-
# representing any ASCII letter (a-zA-Z) and a colon, this function
|
179
|
-
# recognises six sequences: +'X:'+, +'X:\'+, +'X:/'+, +'\\?\X:'+,
|
180
|
-
# +'\\?\X:\'+, +'\\?\X:/'+
|
181
|
-
#
|
182
|
-
# === Return
|
183
|
-
# - +nil+:: if it is not "drived";
|
184
|
-
# - 2:: it begins with the form +'X:'+
|
185
|
-
# - 3:: it begins with the form +'X:\'+ or +'X:/'+
|
186
|
-
# - 6:: it begins with the form +'\\?\X:'+
|
187
|
-
# - 7:: it begins with the form +'\\?\X:\'+ or +'\\?\X:/'+
|
188
|
-
def path_is_letter_drived? path
|
194
|
+
_Drive = Internal_::Windows::Drive
|
195
|
+
_Form = Internal_::Windows::Form
|
189
196
|
|
190
|
-
|
197
|
+
Diagnostics.check_string_parameter(path, "path") if $DEBUG
|
191
198
|
|
192
|
-
|
199
|
+
if path.size >= 2
|
193
200
|
|
194
|
-
|
201
|
+
base_index = 0
|
195
202
|
|
196
|
-
|
203
|
+
if '\\' == path[0]
|
197
204
|
|
198
|
-
|
205
|
+
if '\\' == path[1]
|
199
206
|
|
200
|
-
|
207
|
+
if '?' == path[2]
|
201
208
|
|
202
|
-
|
209
|
+
if '\\' == path[3]
|
203
210
|
|
204
|
-
|
211
|
+
base_index = 4
|
212
|
+
end
|
205
213
|
end
|
206
214
|
end
|
207
215
|
end
|
208
|
-
end
|
209
216
|
|
210
|
-
|
217
|
+
if ':' == path[base_index + 1]
|
211
218
|
|
212
|
-
|
219
|
+
if _Drive.character_is_drive_letter? path[base_index + 0]
|
213
220
|
|
214
|
-
|
221
|
+
if _Form.char_is_path_name_separator? path[base_index + 2]
|
215
222
|
|
216
|
-
|
217
|
-
|
223
|
+
return 4 == base_index ? 7 : 3
|
224
|
+
else
|
218
225
|
|
219
|
-
|
226
|
+
return 4 == base_index ? 6 : 2
|
227
|
+
end
|
220
228
|
end
|
221
229
|
end
|
222
230
|
end
|
231
|
+
|
232
|
+
nil
|
223
233
|
end
|
224
234
|
|
225
|
-
|
226
|
-
|
235
|
+
# Evaluates whether the given path is homed, which means it is '~' or
|
236
|
+
# begins with '~/' or '~\'
|
237
|
+
#
|
238
|
+
# === Signature
|
239
|
+
#
|
240
|
+
# * *Parameters:*
|
241
|
+
# - +path+:: (String) The path to be evaluated. May not be +nil+
|
242
|
+
def path_is_homed? path
|
227
243
|
|
228
|
-
|
229
|
-
# begins with '~/' or '~\'
|
230
|
-
#
|
231
|
-
# === Signature
|
232
|
-
#
|
233
|
-
# * *Parameters:*
|
234
|
-
# - +path+:: (String) The path to be evaluated. May not be +nil+
|
235
|
-
def path_is_homed? path
|
244
|
+
_Form = Internal_::Windows::Form
|
236
245
|
|
237
|
-
|
246
|
+
Diagnostics.check_string_parameter(path, "path") if $DEBUG
|
238
247
|
|
239
|
-
|
248
|
+
return false unless '~' == path[0]
|
240
249
|
|
241
|
-
|
250
|
+
if path.size > 1
|
242
251
|
|
243
|
-
|
244
|
-
|
252
|
+
return _Form.char_is_path_name_separator? path[1]
|
253
|
+
end
|
245
254
|
|
246
|
-
|
247
|
-
|
255
|
+
true
|
256
|
+
end
|
248
257
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
258
|
+
# Evalutes whether the given path is rooted, which means it begins with
|
259
|
+
# '/'
|
260
|
+
#
|
261
|
+
# === Signature
|
262
|
+
#
|
263
|
+
# * *Parameters:*
|
264
|
+
# - +path+:: (String) The path to be evaluated. May not be +nil+
|
265
|
+
def path_is_rooted? path
|
257
266
|
|
258
|
-
|
267
|
+
_Drive = Internal_::Windows::Drive
|
268
|
+
_Form = Internal_::Windows::Form
|
259
269
|
|
260
|
-
|
261
|
-
when '/'
|
270
|
+
Diagnostics.check_string_parameter(path, "path") if $DEBUG
|
262
271
|
|
263
|
-
|
264
|
-
|
272
|
+
case path[0]
|
273
|
+
when '/'
|
265
274
|
|
266
|
-
|
275
|
+
true
|
267
276
|
when '\\'
|
268
277
|
|
269
|
-
|
278
|
+
case path[1]
|
279
|
+
when '\\'
|
270
280
|
|
271
|
-
|
281
|
+
vol, rem, _ = _Form.get_windows_volume(path)
|
272
282
|
|
273
|
-
|
283
|
+
return false unless vol
|
274
284
|
|
275
|
-
|
285
|
+
if rem && _Form.char_is_path_name_separator?(rem[0])
|
286
|
+
|
287
|
+
true
|
288
|
+
else
|
289
|
+
|
290
|
+
false
|
291
|
+
end
|
276
292
|
else
|
277
293
|
|
278
|
-
|
294
|
+
true
|
279
295
|
end
|
280
296
|
else
|
281
297
|
|
282
|
-
|
283
|
-
end
|
284
|
-
else
|
298
|
+
if path.size > 2
|
285
299
|
|
286
|
-
|
300
|
+
if ':' == path[1]
|
287
301
|
|
288
|
-
|
302
|
+
if _Drive.character_is_drive_letter? path[0]
|
289
303
|
|
290
|
-
|
291
|
-
|
292
|
-
return Internal_::Windows::Form.char_is_path_name_separator? path[2]
|
304
|
+
return _Form.char_is_path_name_separator? path[2]
|
305
|
+
end
|
293
306
|
end
|
294
307
|
end
|
295
|
-
end
|
296
308
|
|
297
|
-
|
309
|
+
false
|
310
|
+
end
|
298
311
|
end
|
299
|
-
end
|
300
312
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
313
|
+
# Evalutes whether the given path is UNC
|
314
|
+
#
|
315
|
+
# === Signature
|
316
|
+
#
|
317
|
+
# * *Parameters:*
|
318
|
+
# - +path+:: (String) The path to be evaluated. May not be +nil+
|
319
|
+
def path_is_UNC? path
|
308
320
|
|
309
|
-
|
321
|
+
_Form = Internal_::Windows::Form
|
310
322
|
|
311
|
-
|
312
|
-
return false unless '\\' == path[1]
|
323
|
+
Diagnostics.check_string_parameter(path, "path") if $DEBUG
|
313
324
|
|
314
|
-
|
325
|
+
return false unless '\\' == path[0]
|
326
|
+
return false unless '\\' == path[1]
|
315
327
|
|
316
|
-
|
317
|
-
when :form_2, :form_3, :form_4, :form_5, :form_6
|
328
|
+
_, _, frm = _Form.get_windows_volume(path)
|
318
329
|
|
319
|
-
|
320
|
-
|
330
|
+
case frm
|
331
|
+
when :form_2, :form_3, :form_4, :form_5, :form_6
|
321
332
|
|
322
|
-
|
333
|
+
true
|
334
|
+
else
|
335
|
+
|
336
|
+
false
|
337
|
+
end
|
323
338
|
end
|
324
|
-
end
|
339
|
+
end # module LibPath_Form_Windows_Methods
|
325
340
|
|
326
|
-
|
341
|
+
# @!visibility private
|
342
|
+
def self.extended receiver # :nodoc:
|
327
343
|
|
328
|
-
|
329
|
-
def self.extended receiver # :nodoc:
|
344
|
+
receiver.class_eval do
|
330
345
|
|
331
|
-
|
346
|
+
extend LibPath_Form_Windows_Methods
|
347
|
+
end
|
332
348
|
|
333
|
-
|
349
|
+
$stderr.puts "#{receiver} extended by #{LibPath_Form_Windows_Methods}" if $DEBUG
|
334
350
|
end
|
335
351
|
|
336
|
-
|
337
|
-
|
352
|
+
# @!visibility private
|
353
|
+
def self.included receiver # :nodoc:
|
338
354
|
|
339
|
-
|
340
|
-
def self.included receiver # :nodoc:
|
355
|
+
receiver.class_eval do
|
341
356
|
|
342
|
-
|
357
|
+
include LibPath_Form_Windows_Methods
|
358
|
+
end
|
343
359
|
|
344
|
-
|
360
|
+
$stderr.puts "#{receiver} included #{LibPath_Form_Windows_Methods}" if $DEBUG
|
345
361
|
end
|
346
362
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
extend LibPath_Form_Windows_Methods
|
351
|
-
include LibPath_Form_Windows_Methods
|
363
|
+
extend LibPath_Form_Windows_Methods
|
364
|
+
include LibPath_Form_Windows_Methods
|
352
365
|
|
353
366
|
end # module Windows
|
354
367
|
end # module Form
|
data/lib/libpath/form.rb
CHANGED
@@ -9,8 +9,8 @@ else
|
|
9
9
|
require 'libpath/form/unix'
|
10
10
|
end
|
11
11
|
|
12
|
-
module LibPath
|
13
|
-
module Form
|
12
|
+
module LibPath
|
13
|
+
module Form
|
14
14
|
|
15
15
|
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
16
16
|
|
@@ -33,7 +33,6 @@ module Form # :nodoc:
|
|
33
33
|
|
34
34
|
$stderr.puts "#{receiver} included #{self}" if $DEBUG
|
35
35
|
end
|
36
|
-
|
37
36
|
end # module Form
|
38
37
|
end # module LibPath
|
39
38
|
|
@@ -1,94 +1,94 @@
|
|
1
1
|
|
2
2
|
# :stopdoc:
|
3
3
|
|
4
|
-
module LibPath # :nodoc:
|
5
|
-
# @!visibility private
|
6
|
-
module Internal_ # :nodoc: all
|
7
4
|
|
5
|
+
module LibPath
|
8
6
|
# @!visibility private
|
9
|
-
module
|
7
|
+
module Internal_ # :nodoc: all
|
10
8
|
|
11
9
|
# @!visibility private
|
12
|
-
|
10
|
+
module Array # :nodoc:
|
13
11
|
|
14
|
-
|
12
|
+
# @!visibility private
|
13
|
+
def self.index(ar, v, after = nil) # :nodoc:
|
15
14
|
|
16
|
-
if after
|
15
|
+
if after
|
17
16
|
|
18
|
-
after
|
17
|
+
if after < 0
|
19
18
|
|
20
|
-
|
21
|
-
else
|
19
|
+
after = ar.size + after
|
22
20
|
|
23
|
-
|
24
|
-
|
21
|
+
return nil if after < 0
|
22
|
+
else
|
25
23
|
|
26
|
-
|
24
|
+
return nil unless after < ar.size
|
25
|
+
end
|
27
26
|
|
28
|
-
|
27
|
+
ar.each_with_index do |el, ix|
|
29
28
|
|
30
|
-
if
|
29
|
+
if ix >= after
|
31
30
|
|
32
|
-
|
31
|
+
if v == el
|
32
|
+
|
33
|
+
return ix
|
34
|
+
end
|
33
35
|
end
|
34
36
|
end
|
35
|
-
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
nil
|
39
|
+
else
|
39
40
|
|
40
|
-
|
41
|
+
ar.index(v)
|
42
|
+
end
|
41
43
|
end
|
42
|
-
end
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
# @!visibility private
|
46
|
+
def self.index2(ar, v1, v2, after = nil) # :nodoc:
|
46
47
|
|
47
|
-
|
48
|
-
|
48
|
+
i_1 = self.index(ar, v1, after)
|
49
|
+
i_2 = self.index(ar, v2, after)
|
49
50
|
|
50
|
-
|
51
|
+
if i_1
|
51
52
|
|
52
|
-
|
53
|
+
if i_2
|
53
54
|
|
54
|
-
|
55
|
+
i_1 < i_2 ? i_1 : i_2
|
56
|
+
else
|
57
|
+
|
58
|
+
i_1
|
59
|
+
end
|
55
60
|
else
|
56
61
|
|
57
|
-
|
62
|
+
i_2
|
58
63
|
end
|
59
|
-
else
|
60
|
-
|
61
|
-
i_2
|
62
64
|
end
|
63
|
-
end
|
64
65
|
|
65
66
|
|
66
|
-
|
67
|
-
|
67
|
+
# @!visibility private
|
68
|
+
def self.rindex2(ar, v1, v2) # :nodoc:
|
69
|
+
|
70
|
+
i_1 = ar.rindex(v1)
|
71
|
+
i_2 = ar.rindex(v2)
|
68
72
|
|
69
|
-
|
70
|
-
i_2 = ar.rindex(v2)
|
73
|
+
if i_1
|
71
74
|
|
72
|
-
|
75
|
+
if i_2
|
73
76
|
|
74
|
-
|
77
|
+
i_1 < i_2 ? i_2 : i_1
|
78
|
+
else
|
75
79
|
|
76
|
-
|
80
|
+
i_1
|
81
|
+
end
|
77
82
|
else
|
78
83
|
|
79
|
-
|
84
|
+
i_2
|
80
85
|
end
|
81
|
-
else
|
82
|
-
|
83
|
-
i_2
|
84
86
|
end
|
85
|
-
end
|
86
|
-
|
87
|
-
end # module Array
|
88
|
-
|
87
|
+
end # module Array
|
89
88
|
end # module Internal_
|
90
89
|
end # module LibPath
|
91
90
|
|
91
|
+
|
92
92
|
# :startdoc:
|
93
93
|
|
94
94
|
|