Module: KeepYourHead::BaseStatistic
- Defined in:
- lib/Keepyourhead/database/BaseStatistic.rb
Instance Method Summary collapse
- #collectFlashcards ⇒ Object
- #count ⇒ Object
- #countActive ⇒ Object
- #countPassive ⇒ Object
- #distribution ⇒ Object
- #removeStatistics ⇒ Object
Instance Method Details
#collectFlashcards ⇒ Object
21 22 23 24 25 |
# File 'lib/Keepyourhead/database/BaseStatistic.rb', line 21 def collectFlashcards items.map{ |item| item.collectFlashcards }.flatten end |
#count ⇒ Object
29 30 31 |
# File 'lib/Keepyourhead/database/BaseStatistic.rb', line 29 def count items.map{ |item| item.count }.inject(0) { |a,b| a+b } end |
#countActive ⇒ Object
32 33 34 |
# File 'lib/Keepyourhead/database/BaseStatistic.rb', line 32 def countActive items.map{ |item| item.countActive }.inject(0) { |a,b| a+b } end |
#countPassive ⇒ Object
35 36 37 |
# File 'lib/Keepyourhead/database/BaseStatistic.rb', line 35 def countPassive items.map{ |item| item.countPassive }.inject(0) { |a,b| a+b } end |
#distribution ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/Keepyourhead/database/BaseStatistic.rb', line 39 def distribution all = items.map{ |item| item.distribution } distribution = [] while all.inject(false) { |ret,set| ret ||= (set.length > 0) } sum = 0 all.each { |set| sum += set.pop || 0 } distribution << sum end distribution = distribution.reverse distribution end |
#removeStatistics ⇒ Object
57 58 59 |
# File 'lib/Keepyourhead/database/BaseStatistic.rb', line 57 def removeStatistics items.each{ |item| item.removeStatistics } end |