Class: HeadMusic::Notation::StaffMapping
- Inherits:
-
Object
- Object
- HeadMusic::Notation::StaffMapping
- Defined in:
- lib/head_music/notation/staff_mapping.rb
Overview
Represents the mapping of an instrument (and optional playing technique) to a staff position
Instance Attribute Summary collapse
-
#instrument_key ⇒ Object
readonly
Returns the value of attribute instrument_key.
-
#playing_technique_key ⇒ Object
readonly
Returns the value of attribute playing_technique_key.
-
#staff_position ⇒ Object
readonly
Returns the value of attribute staff_position.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ StaffMapping
constructor
Initialize a new StaffMapping.
-
#instrument ⇒ Instrument?
Get the Instrument object.
-
#playing_technique ⇒ PlayingTechnique?
Get the PlayingTechnique object.
-
#position_index ⇒ Integer
Get the staff position index.
-
#to_s ⇒ String
String representation of this mapping.
Constructor Details
#initialize(attributes) ⇒ StaffMapping
Initialize a new StaffMapping
30 31 32 33 34 |
# File 'lib/head_music/notation/staff_mapping.rb', line 30 def initialize(attributes) @staff_position = HeadMusic::Notation::StaffPosition.new(attributes["staff_position"].to_i) @instrument_key = attributes["instrument"] @playing_technique_key = attributes["playing_technique"] end |
Instance Attribute Details
#instrument_key ⇒ Object (readonly)
Returns the value of attribute instrument_key.
22 23 24 |
# File 'lib/head_music/notation/staff_mapping.rb', line 22 def instrument_key @instrument_key end |
#playing_technique_key ⇒ Object (readonly)
Returns the value of attribute playing_technique_key.
22 23 24 |
# File 'lib/head_music/notation/staff_mapping.rb', line 22 def @playing_technique_key end |
#staff_position ⇒ Object (readonly)
Returns the value of attribute staff_position.
22 23 24 |
# File 'lib/head_music/notation/staff_mapping.rb', line 22 def staff_position @staff_position end |
Instance Method Details
#instrument ⇒ Instrument?
Get the Instrument object
39 40 41 |
# File 'lib/head_music/notation/staff_mapping.rb', line 39 def instrument HeadMusic::Instruments::Instrument.get(instrument_key) if instrument_key end |
#playing_technique ⇒ PlayingTechnique?
Get the PlayingTechnique object
46 47 48 |
# File 'lib/head_music/notation/staff_mapping.rb', line 46 def HeadMusic::Instruments::PlayingTechnique.get() if end |
#position_index ⇒ Integer
Get the staff position index
53 54 55 |
# File 'lib/head_music/notation/staff_mapping.rb', line 53 def position_index staff_position.index end |
#to_s ⇒ String
String representation of this mapping
63 64 65 66 67 68 69 |
# File 'lib/head_music/notation/staff_mapping.rb', line 63 def to_s parts = [] parts << (instrument&.name || instrument_key) if instrument_key parts << "(#{})" if parts << "at #{staff_position}" parts.compact.join(" ") end |