Class: CandidateTranslator

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

Instance Method Summary collapse

Instance Method Details

#translate(candidates, translation) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/threesmodel/candidate_translator.rb', line 19

def translate(candidates, translation)
  result = []
  for candidate in candidates do
    result << translation[candidate]
  end
  result
end

#translate_down_fold(candidates) ⇒ Object



11
12
13
# File 'lib/threesmodel/candidate_translator.rb', line 11

def translate_down_fold(candidates)
  translate(candidates, {[0,3] => [0,0], [1,3] => [0,1], [2,3] => [0,2], [3,3] => [0,3]})
end

#translate_left_fold(candidates) ⇒ Object



3
4
5
# File 'lib/threesmodel/candidate_translator.rb', line 3

def translate_left_fold(candidates)
  candidates
end

#translate_right_fold(candidates) ⇒ Object



7
8
9
# File 'lib/threesmodel/candidate_translator.rb', line 7

def translate_right_fold(candidates)
  translate(candidates, {[0,3] => [3,0], [1,3] => [2,0], [2,3] => [1,0], [3,3] => [0,0]})
end

#translate_up_fold(candidates) ⇒ Object



15
16
17
# File 'lib/threesmodel/candidate_translator.rb', line 15

def translate_up_fold(candidates)
  translate(candidates, {[0,3] => [3,3], [1,3] => [3,2], [2,3] => [3,1], [3,3] => [3,0]})
end