Class: Array
Instance Method Summary collapse
- #check_all? ⇒ Boolean
- #group_by_count(int) ⇒ Object
- #occurrances_of ⇒ Object
-
#to_hash_via(&block) ⇒ Object
Expects the block to receive each element and return a two-element array.
Instance Method Details
#check_all? ⇒ Boolean
27 28 29 30 31 |
# File 'lib/quickbooks/ruby_ext.rb', line 27 def check_all? passed = true each { |e| passed = false unless yield(e) } passed end |
#group_by_count(int) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/quickbooks/ruby_ext.rb', line 12 def group_by_count(int) ary = [] nxt = 0 until(nxt*4 > length) n = [] int.times do |i| break if nxt*4+i >= length n << self[nxt*4+i] end nxt += 1 ary << n unless n.empty? end ary end |
#occurrances_of ⇒ Object
33 34 35 36 37 |
# File 'lib/quickbooks/ruby_ext.rb', line 33 def occurrances_of count = 0 each { |e| count += 1 if yield(e) } count end |