Class: Array

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

Instance Method Summary collapse

Instance Method Details

#each_until(&block) ⇒ Object

execute block for each element of array, passing the element as the block parameter until the block returns true



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sitebuilder/array.rb', line 5

def each_until(&block)
  return false if empty?
  for i in 0..size-1
    result_true = block.call(self[i]) 
    break if result_true
  end
  if result_true
      return true
    else
      return false
  end
end

#tailObject

return a subarray consisting of elements 2..n of the array (i.e. all except the first element)



20
21
22
23
# File 'lib/sitebuilder/array.rb', line 20

def tail
  return self[1,size-1] if size>1
  return []
end