Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/postview/patches.rb,
lib/postview/extensions.rb

Instance Method Summary collapse

Instance Method Details

#count(obj = nil) ⇒ Object

Count objects in elements.



4
5
6
7
8
9
10
# File 'lib/postview/patches.rb', line 4

def count(obj = nil)
  if block_given?
    select { |item| yield item }.size
  else
    select { |item| item == obj }.size
  end
end

#limit(size) ⇒ Object

Returns elements between first and the specific limit.



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

def limit(size)
  self[0..size - 1]
end