Class: HeadMusic::Staff

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_clefObject (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

#instrumentObject (readonly)

Returns the value of attribute instrument.



5
6
7
# File 'lib/head_music/staff.rb', line 5

def instrument
  @instrument
end

#line_countObject (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

#clefObject



13
14
15
# File 'lib/head_music/staff.rb', line 13

def clef
  default_clef || instrument&.default_staves&.first&.clef
end