Class: Evaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/Evaluator.rb

Class Method Summary collapse

Class Method Details

.exacts(zipped_array) ⇒ Object


2
3
4
# File 'lib/Evaluator.rb', line 2

def self.exacts(zipped_array)
  zipped_array.select{|x| x[0] == x[1]}.count
end

.format_time(total_time) ⇒ Object


23
24
25
26
27
28
29
# File 'lib/Evaluator.rb', line 23

def self.format_time(total_time)
  if(total_time > 60)
    total_time = "#{total_time/60}m#{(total_time%60).to_i}s"
  else
    total_time ="#{total_time.to_i}s"
  end
end

.partials(zipped_array) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/Evaluator.rb', line 6

def self.partials(zipped_array)
  # Remove all the exact match
  zipped_array.select!{|x| x[0] != x[1]}
  # Seperate computer from user
  comp, user = zipped_array.transpose
  partials = []
  if(user !=nil)
    user.each do |a|
          if comp.include? a
            comp.delete_at(comp.index(a))
            partials << a
          end
    end
  end
  partials.size
end