Class: Fet::Ui::NoteBoxes

Inherits:
Object
  • Object
show all
Defined in:
lib/fet/ui/note_boxes.rb

Overview

Class that handles draw all degree boxes

Constant Summary collapse

GLOBAL_X_OFFSET =
60
GLOBAL_Y_OFFSET =
244
NOTE_BOX_OFFSETS =
{
  "1" => [(GLOBAL_X_OFFSET + 0), GLOBAL_Y_OFFSET + 75],
  "2" => [(GLOBAL_X_OFFSET + 75), GLOBAL_Y_OFFSET + 75],
  "3" => [(GLOBAL_X_OFFSET + 150), GLOBAL_Y_OFFSET + 75],
  "4" => [(GLOBAL_X_OFFSET + 225), GLOBAL_Y_OFFSET + 75],
  "5" => [(GLOBAL_X_OFFSET + 300), GLOBAL_Y_OFFSET + 75],
  "6" => [(GLOBAL_X_OFFSET + 375), GLOBAL_Y_OFFSET + 75],
  "7" => [(GLOBAL_X_OFFSET + 450), GLOBAL_Y_OFFSET + 75],
  "b2" => [(GLOBAL_X_OFFSET + 40), GLOBAL_Y_OFFSET],
  "b3" => [(GLOBAL_X_OFFSET + 115), GLOBAL_Y_OFFSET],
  "b5" => [(GLOBAL_X_OFFSET + 265), GLOBAL_Y_OFFSET],
  "b6" => [(GLOBAL_X_OFFSET + 340), GLOBAL_Y_OFFSET],
  "b7" => [(GLOBAL_X_OFFSET + 415), GLOBAL_Y_OFFSET],
}.deep_freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ NoteBoxes

Returns a new instance of NoteBoxes.



26
27
28
# File 'lib/fet/ui/note_boxes.rb', line 26

def initialize(level)
  self.level = level
end

Instance Attribute Details

#levelObject

Returns the value of attribute level.



7
8
9
# File 'lib/fet/ui/note_boxes.rb', line 7

def level
  @level
end

#note_boxesObject

Returns the value of attribute note_boxes.



7
8
9
# File 'lib/fet/ui/note_boxes.rb', line 7

def note_boxes
  @note_boxes
end

Instance Method Details

#all_correct_selected?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/fet/ui/note_boxes.rb', line 42

def all_correct_selected?
  return (correct_note_boxes.map(&:degree_name) & selected_note_boxes.map(&:degree_name)).size == correct_note_boxes.size
end

#any_wrong_selected?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/fet/ui/note_boxes.rb', line 46

def any_wrong_selected?
  return selected_note_boxes.any? { |note_box| !note_box.correct? }
end

#correct_note_boxesObject



54
55
56
# File 'lib/fet/ui/note_boxes.rb', line 54

def correct_note_boxes
  return note_boxes.select(&:correct?)
end

#correct_remainingObject



50
51
52
# File 'lib/fet/ui/note_boxes.rb', line 50

def correct_remaining
  return note_boxes.select { |note_box| !note_box.selected && note_box.correct? }
end

#handle_event_loop(event) ⇒ Object



35
36
37
38
# File 'lib/fet/ui/note_boxes.rb', line 35

def handle_event_loop(event)
  handle_note_selected_event(event)
  note_boxes.each { |note_box| note_box.handle_event_loop(event) }
end

#handle_update_loopObject



40
# File 'lib/fet/ui/note_boxes.rb', line 40

def handle_update_loop; end

#selected_note_boxesObject



58
59
60
# File 'lib/fet/ui/note_boxes.rb', line 58

def selected_note_boxes
  return note_boxes.select(&:selected)
end

#startObject



30
31
32
33
# File 'lib/fet/ui/note_boxes.rb', line 30

def start
  self.note_boxes ||= generate_note_boxes
  note_boxes.each(&:start)
end