Class: HeadMusic::Content::Bar
- Inherits:
-
Object
- Object
- HeadMusic::Content::Bar
- Defined in:
- lib/head_music/content/bar.rb
Overview
Representation of a bar in a composition Encapsulates meter and key signature changes
Instance Attribute Summary collapse
-
#composition ⇒ Object
readonly
Returns the value of attribute composition.
-
#key_signature ⇒ Object
Returns the value of attribute key_signature.
-
#meter ⇒ Object
Returns the value of attribute meter.
Instance Method Summary collapse
-
#initialize(composition, key_signature: nil, meter: nil) ⇒ Bar
constructor
A new instance of Bar.
- #to_s ⇒ Object
Constructor Details
#initialize(composition, key_signature: nil, meter: nil) ⇒ Bar
Returns a new instance of Bar.
10 11 12 13 14 |
# File 'lib/head_music/content/bar.rb', line 10 def initialize(composition, key_signature: nil, meter: nil) @composition = composition @key_signature = HeadMusic::Rudiment::KeySignature.get(key_signature) if key_signature @meter = HeadMusic::Rudiment::Meter.get(meter) if meter end |
Instance Attribute Details
#composition ⇒ Object (readonly)
Returns the value of attribute composition.
7 8 9 |
# File 'lib/head_music/content/bar.rb', line 7 def composition @composition end |
#key_signature ⇒ Object
Returns the value of attribute key_signature.
8 9 10 |
# File 'lib/head_music/content/bar.rb', line 8 def key_signature @key_signature end |
#meter ⇒ Object
Returns the value of attribute meter.
8 9 10 |
# File 'lib/head_music/content/bar.rb', line 8 def meter @meter end |
Instance Method Details
#to_s ⇒ Object
16 17 18 |
# File 'lib/head_music/content/bar.rb', line 16 def to_s ["Bar", key_signature, meter].compact.join(" ") end |