Class: HeadMusic::Content::Note
- Inherits:
-
Object
- Object
- HeadMusic::Content::Note
- Defined in:
- lib/head_music/content/note.rb
Overview
A note is a pitch with a duration.
Note quacks like a placement, but requires a different set of construction arguments
- always has a pitch
- receives a voice and position if unspecified
Instance Attribute Summary collapse
-
#pitch ⇒ Object
Returns the value of attribute pitch.
-
#position ⇒ Object
Returns the value of attribute position.
-
#rhythmic_value ⇒ Object
Returns the value of attribute rhythmic_value.
-
#voice ⇒ Object
Returns the value of attribute voice.
Instance Method Summary collapse
-
#initialize(pitch, rhythmic_value, voice = nil, position = nil) ⇒ Note
constructor
A new instance of Note.
- #method_missing(method_name, *args, &block) ⇒ Object
- #placement ⇒ Object
- #respond_to_missing?(method_name, *_args) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(pitch, rhythmic_value, voice = nil, position = nil) ⇒ Note
Returns a new instance of Note.
14 15 16 17 18 19 |
# File 'lib/head_music/content/note.rb', line 14 def initialize(pitch, rhythmic_value, voice = nil, position = nil) @pitch = HeadMusic::Pitch.get(pitch) @rhythmic_value = HeadMusic::Content::RhythmicValue.get(rhythmic_value) @voice = voice || HeadMusic::Content::Voice.new @position = position || HeadMusic::Content::Position.new(@voice.composition, "1:1") end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
29 30 31 |
# File 'lib/head_music/content/note.rb', line 29 def method_missing(method_name, *args, &block) respond_to_missing?(method_name) ? placement.send(method_name, *args, &block) : super end |
Instance Attribute Details
#pitch ⇒ Object
Returns the value of attribute pitch.
12 13 14 |
# File 'lib/head_music/content/note.rb', line 12 def pitch @pitch end |
#position ⇒ Object
Returns the value of attribute position.
12 13 14 |
# File 'lib/head_music/content/note.rb', line 12 def position @position end |
#rhythmic_value ⇒ Object
Returns the value of attribute rhythmic_value.
12 13 14 |
# File 'lib/head_music/content/note.rb', line 12 def rhythmic_value @rhythmic_value end |
#voice ⇒ Object
Returns the value of attribute voice.
12 13 14 |
# File 'lib/head_music/content/note.rb', line 12 def voice @voice end |
Instance Method Details
#placement ⇒ Object
21 22 23 |
# File 'lib/head_music/content/note.rb', line 21 def placement @placement ||= HeadMusic::Content::Placement.new(voice, position, rhythmic_value, pitch) end |
#respond_to_missing?(method_name, *_args) ⇒ Boolean
33 34 35 |
# File 'lib/head_music/content/note.rb', line 33 def respond_to_missing?(method_name, *_args) placement.respond_to?(method_name) end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/head_music/content/note.rb', line 25 def to_s "#{pitch} at #{position}" end |