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

#instrumentObject (readonly)

Returns the value of attribute instrument.



7
8
9
# File 'lib/head_music/staff.rb', line 7

def instrument
  @instrument
end

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

#clefObject



15
16
17
# File 'lib/head_music/staff.rb', line 15

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