Class: Fet::Ui::NoteBox

Inherits:
Object
  • Object
show all
Includes:
NoteBoxLoopHandler
Defined in:
lib/fet/ui/note_box.rb

Overview

Handles drawing + events for notes

Instance Attribute Summary collapse

Attributes included from NoteBoxLoopHandler

#user_selected

Instance Method Summary collapse

Methods included from NoteBoxLoopHandler

#handle_event_loop, #handle_update_loop, #manually_select

Constructor Details

#initialize(note_boxes:, degree_name:) ⇒ NoteBox

Returns a new instance of NoteBox.



15
16
17
18
# File 'lib/fet/ui/note_box.rb', line 15

def initialize(note_boxes:, degree_name:)
  self.note_boxes = note_boxes
  self.degree_name = degree_name
end

Instance Attribute Details

#degree_nameObject

Returns the value of attribute degree_name.



13
14
15
# File 'lib/fet/ui/note_box.rb', line 13

def degree_name
  @degree_name
end

#note_boxesObject

Returns the value of attribute note_boxes.



13
14
15
# File 'lib/fet/ui/note_box.rb', line 13

def note_boxes
  @note_boxes
end

#selectedObject

Returns the value of attribute selected.



13
14
15
# File 'lib/fet/ui/note_box.rb', line 13

def selected
  @selected
end

Instance Method Details

#correct?Boolean

Returns:

  • (Boolean)


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

def correct?
  return note_boxes.level.degree_indices.include?(degree_index)
end

#degree_indexObject



34
35
36
# File 'lib/fet/ui/note_box.rb', line 34

def degree_index
  degree_instance.degree_index
end

#startObject



20
21
22
23
24
25
26
27
28
# File 'lib/fet/ui/note_box.rb', line 20

def start
  self.keyboard_accidental = ""
  self.square ||= generate_square
  self.text ||= generate_text
  self.selected = false
  self.user_selected = false
  self.note_music = generate_note_music
  update_colors
end