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, instrument: nil, line_count: nil) ⇒ Staff
constructor
A new instance of Staff.
Constructor Details
#initialize(default_clef, instrument: nil, line_count: nil) ⇒ Staff
Returns a new instance of Staff.
9 10 11 12 13 |
# File 'lib/head_music/staff.rb', line 9 def initialize(default_clef, instrument: nil, line_count: nil) @default_clef = HeadMusic::Clef.get(default_clef) @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.
7 8 9 |
# File 'lib/head_music/staff.rb', line 7 def default_clef @default_clef end |
#instrument ⇒ Object (readonly)
Returns the value of attribute instrument.
7 8 9 |
# File 'lib/head_music/staff.rb', line 7 def instrument @instrument end |
#line_count ⇒ Object (readonly)
Returns the value of attribute line_count.
7 8 9 |
# File 'lib/head_music/staff.rb', line 7 def line_count @line_count end |
Instance Method Details
#clef ⇒ Object
15 16 17 |
# File 'lib/head_music/staff.rb', line 15 def clef default_clef || instrument&.default_staffs&.first end |