Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/matte.rb

Instance Method Summary collapse

Instance Method Details

#select_recursive(&proc) ⇒ Object

like find, but recursive



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/matte.rb', line 9

def select_recursive &proc
    results = []
    each do |element|
        if proc.call element
            results << element
        end 
        if element.is_a? Array
            results.push *(element.select_recursive(&proc))
        end
    end

    results
end

#start_with?(other) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/matte.rb', line 4

def start_with? other
    take(other.length) == other
end