Class: MobyUtil::ArrayHelper
Class Method Summary collapse
Class Method Details
.rindex_regexp(array, pattern) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/tdriver/util/common/array.rb', line 24 def self.rindex_regexp( array, pattern ) array.check_type Array, 'wrong argument type $1 for array (expected $2)' pattern.check_type Regexp, 'wrong argument type $1 for regular expression pattern (expected $2)' # return nil if no matches found, otherwise return index of value return nil if ( array.reverse.each_index{ | index | return @rindex if array[ ( @rindex = ( ( array.size-1 ) - index ) ) ] =~ pattern; } ) end |