Class: HeadMusic::Instrument::Staff

Inherits:
Object
  • Object
show all
Defined in:
lib/head_music/instrument/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.



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

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#staff_schemeObject (readonly)

Returns the value of attribute staff_scheme.



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

def staff_scheme
  @staff_scheme
end

Instance Method Details

#clefObject



11
12
13
# File 'lib/head_music/instrument/staff.rb', line 11

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

#nameObject



27
28
29
# File 'lib/head_music/instrument/staff.rb', line 27

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

#name_keyObject



23
24
25
# File 'lib/head_music/instrument/staff.rb', line 23

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

#smart_clef_keyObject



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

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

#sounding_transpositionObject



19
20
21
# File 'lib/head_music/instrument/staff.rb', line 19

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