Class: HeadMusic::Content::Staff
- Inherits:
-
Object
- Object
- HeadMusic::Content::Staff
- Defined in:
- lib/head_music/content/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.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/head_music/content/staff.rb', line 10 def initialize(default_clef_key, instrument: nil, line_count: nil) @instrument = HeadMusic::Instruments::InstrumentType.get(instrument) if instrument begin @default_clef = HeadMusic::Rudiment::Clef.get(default_clef_key) rescue KeyError, NoMethodError puts("Warning: Clef '#{default_clef_key}' not found.") if @instrument puts("Using instrument clef.") @default_clef = @instrument.default_staves.first.clef else @default_clef = HeadMusic::Rudiment::Clef.get(:treble_clef) end end @line_count = line_count || DEFAULT_LINE_COUNT end |
Instance Attribute Details
#default_clef ⇒ Object (readonly)
Returns the value of attribute default_clef.
8 9 10 |
# File 'lib/head_music/content/staff.rb', line 8 def default_clef @default_clef end |
#instrument ⇒ Object (readonly)
Returns the value of attribute instrument.
8 9 10 |
# File 'lib/head_music/content/staff.rb', line 8 def instrument @instrument end |
#line_count ⇒ Object (readonly)
Returns the value of attribute line_count.
8 9 10 |
# File 'lib/head_music/content/staff.rb', line 8 def line_count @line_count end |
Instance Method Details
#clef ⇒ Object
26 27 28 |
# File 'lib/head_music/content/staff.rb', line 26 def clef default_clef end |