Class: Clef::Core::Chord
- Inherits:
-
Object
- Object
- Clef::Core::Chord
- Defined in:
- lib/clef/core/chord.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#pitches ⇒ Object
readonly
Returns the value of attribute pitches.
Instance Method Summary collapse
-
#initialize(pitches, duration) ⇒ Chord
constructor
A new instance of Chord.
- #length ⇒ Rational
- #sorted_pitches ⇒ Array<Pitch>
Constructor Details
#initialize(pitches, duration) ⇒ Chord
Returns a new instance of Chord.
10 11 12 13 14 15 16 |
# File 'lib/clef/core/chord.rb', line 10 def initialize(pitches, duration) validate_pitches!(pitches) raise ArgumentError, "duration must be a Clef::Core::Duration" unless duration.is_a?(Duration) @pitches = Array(pitches).freeze @duration = duration end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/clef/core/chord.rb', line 6 def duration @duration end |
#pitches ⇒ Object (readonly)
Returns the value of attribute pitches.
6 7 8 |
# File 'lib/clef/core/chord.rb', line 6 def pitches @pitches end |
Instance Method Details
#length ⇒ Rational
19 20 21 |
# File 'lib/clef/core/chord.rb', line 19 def length duration.length end |
#sorted_pitches ⇒ Array<Pitch>
24 25 26 |
# File 'lib/clef/core/chord.rb', line 24 def sorted_pitches pitches.sort end |