Class: HeadMusic::Instruments::Staff

Inherits:
Object
  • Object
show all
Defined in:
lib/head_music/instruments/staff.rb

Constant Summary collapse

DEFAULT_CLEF =
"treble_clef"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(staff_scheme, attributes) ⇒ Staff

Returns a new instance of Staff.



9
10
11
12
# File 'lib/head_music/instruments/staff.rb', line 9

def initialize(staff_scheme, attributes)
  @staff_scheme = staff_scheme
  @attributes = attributes || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#staff_schemeObject (readonly)

Returns the value of attribute staff_scheme.



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

def staff_scheme
  @staff_scheme
end

Instance Method Details

#clefObject



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

def clef
  HeadMusic::Rudiment::Clef.get(smart_clef_key)
end

#nameObject



30
31
32
# File 'lib/head_music/instruments/staff.rb', line 30

def name
  name_key.to_s.tr("_", " ")
end

#name_keyObject



26
27
28
# File 'lib/head_music/instruments/staff.rb', line 26

def name_key
  attributes["name_key"] || ""
end

#smart_clef_keyObject



18
19
20
# File 'lib/head_music/instruments/staff.rb', line 18

def smart_clef_key
  "#{attributes["clef"]}_clef".gsub(/_clef_clef$/, "_clef")
end

#sounding_transpositionObject



22
23
24
# File 'lib/head_music/instruments/staff.rb', line 22

def sounding_transposition
  attributes["sounding_transposition"] || 0
end