Class: TimeArray::Vector

Inherits:
Array
  • Object
show all
Defined in:
lib/time_array/vector.rb

Instance Method Summary collapse

Methods included from ArrayExt

included

Instance Method Details

#+(o) ⇒ Object



47
48
49
# File 'lib/time_array/vector.rb', line 47

def +(o)
  Vector.new(super(o)) # recast
end

#cloneObject



3
4
5
# File 'lib/time_array/vector.rb', line 3

def clone
  Vector.new(self)
end

#count_allObject



43
44
45
# File 'lib/time_array/vector.rb', line 43

def count_all
  size
end

#count_negativeObject



31
32
33
# File 'lib/time_array/vector.rb', line 31

def count_negative
  count{|e| e<0.0}
end

#count_non_negativeObject



27
28
29
# File 'lib/time_array/vector.rb', line 27

def count_non_negative
  count{|e| e>=0.0}
end

#count_non_positiveObject



23
24
25
# File 'lib/time_array/vector.rb', line 23

def count_non_positive
  count{|e| e<=0.0}
end

#count_non_zeroObject



35
36
37
# File 'lib/time_array/vector.rb', line 35

def count_non_zero
  count{|e| e!=0.0}
end

#count_positiveObject



19
20
21
# File 'lib/time_array/vector.rb', line 19

def count_positive
  count{|e| e>0.0}
end

#count_zeroObject



39
40
41
# File 'lib/time_array/vector.rb', line 39

def count_zero
  count{|e| e==0.0}
end

#sum_allObject



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_negativeObject



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_positiveObject



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