Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/crosslanguagespotter/methods/jaro.rb

Instance Method Summary collapse

Instance Method Details

#aindices(o) ⇒ Object

return indices array of array item example all indices of a in string “aaabaaabba”



15
16
17
18
19
20
# File 'lib/crosslanguagespotter/methods/jaro.rb', line 15

def aindices(o)
    out = Array.new
    select_with_index { |x, i|
    out << i if x == o }
    out
end

#select_with_indexObject

select array items with index give a block both the item with index of array filtered by a select statement



8
9
10
11
# File 'lib/crosslanguagespotter/methods/jaro.rb', line 8

def select_with_index
    index = -1
    select { |x| index += 1; yield(x, index) }
end