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.
12 13 14 15 16 17 |
# File 'lib/head_music/content/note.rb', line 12 def initialize(pitch, rhythmic_value, voice = nil, position = nil) @pitch = HeadMusic::Rudiment::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
27 28 29 |
# File 'lib/head_music/content/note.rb', line 27 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.
10 11 12 |
# File 'lib/head_music/content/note.rb', line 10 def pitch @pitch end |
#position ⇒ Object
Returns the value of attribute position.
10 11 12 |
# File 'lib/head_music/content/note.rb', line 10 def position @position end |
#rhythmic_value ⇒ Object
Returns the value of attribute rhythmic_value.
10 11 12 |
# File 'lib/head_music/content/note.rb', line 10 def rhythmic_value @rhythmic_value end |
#voice ⇒ Object
Returns the value of attribute voice.
10 11 12 |
# File 'lib/head_music/content/note.rb', line 10 def voice @voice end |
Instance Method Details
#placement ⇒ Object
19 20 21 |
# File 'lib/head_music/content/note.rb', line 19 def placement @placement ||= HeadMusic::Content::Placement.new(voice, position, rhythmic_value, pitch) end |
#respond_to_missing?(method_name, *_args) ⇒ Boolean
31 32 33 |
# File 'lib/head_music/content/note.rb', line 31 def respond_to_missing?(method_name, *_args) placement.respond_to?(method_name) end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/head_music/content/note.rb', line 23 def to_s "#{pitch} at #{position}" end |