Class: HeadMusic::Staff
- Inherits:
-
Object
- Object
- HeadMusic::Staff
- Defined in:
- lib/head_music/staff.rb
Overview
A staff is a set of lines and spaces that provides context for a pitch
Constant Summary collapse
- DEFAULT_LINE_COUNT =
5
Instance Attribute Summary collapse
-
#default_clef ⇒ Object
readonly
Returns the value of attribute default_clef.
-
#instrument ⇒ Object
readonly
Returns the value of attribute instrument.
-
#line_count ⇒ Object
readonly
Returns the value of attribute line_count.
Instance Method Summary collapse
- #clef ⇒ Object
-
#initialize(default_clef_key, instrument: nil, line_count: nil) ⇒ Staff
constructor
A new instance of Staff.
Constructor Details
#initialize(default_clef_key, instrument: nil, line_count: nil) ⇒ Staff
Returns a new instance of Staff.
7 8 9 10 11 |
# File 'lib/head_music/staff.rb', line 7 def initialize(default_clef_key, instrument: nil, line_count: nil) @default_clef = HeadMusic::Clef.get(default_clef_key) @line_count = line_count || DEFAULT_LINE_COUNT @instrument = HeadMusic::Instrument.get(instrument) if instrument end |
Instance Attribute Details
#default_clef ⇒ Object (readonly)
Returns the value of attribute default_clef.
5 6 7 |
# File 'lib/head_music/staff.rb', line 5 def default_clef @default_clef end |
#instrument ⇒ Object (readonly)
Returns the value of attribute instrument.
5 6 7 |
# File 'lib/head_music/staff.rb', line 5 def instrument @instrument end |
#line_count ⇒ Object (readonly)
Returns the value of attribute line_count.
5 6 7 |
# File 'lib/head_music/staff.rb', line 5 def line_count @line_count end |
Instance Method Details
#clef ⇒ Object
13 14 15 |
# File 'lib/head_music/staff.rb', line 13 def clef default_clef || instrument&.default_staves&.first&.clef end |