Method: Oscillo::Enumerable#count
- Defined in:
- lib/oscillo/enumerable.rb
#count ⇒ Object #count(obj) ⇒ Object #count {|value| ... } ⇒ Object
Note:
Only takes in to consideration values from the time the signal was created.
Returns the number values that the signal has had. If an argument is given, counts the number of values in the signal, for which equals to item. If a block is given, counts the number of values yielding a true value.
109 110 111 112 113 114 115 116 |
# File 'lib/oscillo/enumerable.rb', line 109 def count(obj=NO_ARG, &block) return count_with_arg(obj) unless obj.equal?(NO_ARG) return count_with_block(&block) if block_given? self.class.new(0, self) do |v, s| s.val + 1 end end |