Class: TimeArray::Vector
Instance Method Summary collapse
- #+(o) ⇒ Object
- #clone ⇒ Object
- #count_all ⇒ Object
- #count_negative ⇒ Object
- #count_non_negative ⇒ Object
- #count_non_positive ⇒ Object
- #count_non_zero ⇒ Object
- #count_positive ⇒ Object
- #count_zero ⇒ Object
- #sum_all ⇒ Object
- #sum_negative ⇒ Object
- #sum_positive ⇒ Object
Methods included from ArrayExt
Instance Method Details
#+(o) ⇒ Object
47 48 49 |
# File 'lib/time_array/vector.rb', line 47 def +(o) Vector.new(super(o)) # recast end |
#clone ⇒ Object
3 4 5 |
# File 'lib/time_array/vector.rb', line 3 def clone Vector.new(self) end |
#count_all ⇒ Object
43 44 45 |
# File 'lib/time_array/vector.rb', line 43 def count_all size end |
#count_negative ⇒ Object
31 32 33 |
# File 'lib/time_array/vector.rb', line 31 def count_negative count{|e| e<0.0} end |
#count_non_negative ⇒ Object
27 28 29 |
# File 'lib/time_array/vector.rb', line 27 def count_non_negative count{|e| e>=0.0} end |
#count_non_positive ⇒ Object
23 24 25 |
# File 'lib/time_array/vector.rb', line 23 def count_non_positive count{|e| e<=0.0} end |
#count_non_zero ⇒ Object
35 36 37 |
# File 'lib/time_array/vector.rb', line 35 def count_non_zero count{|e| e!=0.0} end |
#count_positive ⇒ Object
19 20 21 |
# File 'lib/time_array/vector.rb', line 19 def count_positive count{|e| e>0.0} end |
#count_zero ⇒ Object
39 40 41 |
# File 'lib/time_array/vector.rb', line 39 def count_zero count{|e| e==0.0} end |
#sum_all ⇒ Object
7 8 9 |
# File 'lib/time_array/vector.rb', line 7 def sum_all inject(0.0){|total, n| total + (n||0.0) } end |
#sum_negative ⇒ Object
15 16 17 |
# File 'lib/time_array/vector.rb', line 15 def sum_negative inject(0.0){|total, n| total + (n<0.0 ? n : 0.0) } end |
#sum_positive ⇒ Object
11 12 13 |
# File 'lib/time_array/vector.rb', line 11 def sum_positive inject(0.0){|total, n| total + (n>0.0 ? n : 0.0) } end |