Class: Musicality::Instrument
- Inherits:
-
Object
- Object
- Musicality::Instrument
- Defined in:
- lib/musicality/notation/model/instrument.rb
Constant Summary collapse
- TREBLE =
:treble
- BASS =
:bass
- TENOR =
:tenor
- ALTO =
:alto
- CLEFS =
[TREBLE, ALTO, BASS, TENOR]
- DEFAULT_MIDI_OPT =
:default
Instance Attribute Summary collapse
-
#clefs ⇒ Object
Returns the value of attribute clefs.
-
#midi_num ⇒ Object
Returns the value of attribute midi_num.
-
#name ⇒ Object
Returns the value of attribute name.
-
#transpose_interval ⇒ Object
Returns the value of attribute transpose_interval.
Class Method Summary collapse
- .bass(name, midi_num, transpose_interval = 0) ⇒ Object
- .bass_guitar(name, midi_num) ⇒ Object
- .guitar(name, midi_num) ⇒ Object
- .tenor_bass(name, midi_num, transpose_interval = 0) ⇒ Object
- .treble(name, midi_num, transpose_interval = 0) ⇒ Object
- .treble_alto(name, midi_num, transpose_interval = 0) ⇒ Object
- .treble_bass(name, midi_num, transpose_interval = 0) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, clefs, midi_num, transpose_interval = 0) ⇒ Instrument
constructor
A new instance of Instrument.
Constructor Details
#initialize(name, clefs, midi_num, transpose_interval = 0) ⇒ Instrument
Returns a new instance of Instrument.
14 15 16 17 18 19 |
# File 'lib/musicality/notation/model/instrument.rb', line 14 def initialize name, clefs, midi_num, transpose_interval = 0 @name = name @clefs = clefs @midi_num = midi_num @transpose_interval = transpose_interval end |
Instance Attribute Details
#clefs ⇒ Object
Returns the value of attribute clefs.
12 13 14 |
# File 'lib/musicality/notation/model/instrument.rb', line 12 def clefs @clefs end |
#midi_num ⇒ Object
Returns the value of attribute midi_num.
12 13 14 |
# File 'lib/musicality/notation/model/instrument.rb', line 12 def midi_num @midi_num end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/musicality/notation/model/instrument.rb', line 12 def name @name end |
#transpose_interval ⇒ Object
Returns the value of attribute transpose_interval.
12 13 14 |
# File 'lib/musicality/notation/model/instrument.rb', line 12 def transpose_interval @transpose_interval end |
Class Method Details
.bass(name, midi_num, transpose_interval = 0) ⇒ Object
36 37 38 |
# File 'lib/musicality/notation/model/instrument.rb', line 36 def self.bass name, midi_num, transpose_interval = 0 Instrument.new(name, [BASS], midi_num, transpose_interval) end |
.bass_guitar(name, midi_num) ⇒ Object
56 57 58 |
# File 'lib/musicality/notation/model/instrument.rb', line 56 def self.bass_guitar name, midi_num Instrument.new(name, [BASS], midi_num, 12) end |
.guitar(name, midi_num) ⇒ Object
52 53 54 |
# File 'lib/musicality/notation/model/instrument.rb', line 52 def self.guitar name, midi_num Instrument.new(name, [TENOR], midi_num, 12) end |
.tenor_bass(name, midi_num, transpose_interval = 0) ⇒ Object
48 49 50 |
# File 'lib/musicality/notation/model/instrument.rb', line 48 def self.tenor_bass name, midi_num, transpose_interval = 0 Instrument.new(name, [TENOR, BASS], midi_num, transpose_interval) end |
.treble(name, midi_num, transpose_interval = 0) ⇒ Object
32 33 34 |
# File 'lib/musicality/notation/model/instrument.rb', line 32 def self.treble name, midi_num, transpose_interval = 0 Instrument.new(name, [TREBLE], midi_num, transpose_interval) end |
.treble_alto(name, midi_num, transpose_interval = 0) ⇒ Object
44 45 46 |
# File 'lib/musicality/notation/model/instrument.rb', line 44 def self.treble_alto name, midi_num, transpose_interval = 0 Instrument.new(name, [TREBLE,ALTO], midi_num, transpose_interval) end |
.treble_bass(name, midi_num, transpose_interval = 0) ⇒ Object
40 41 42 |
# File 'lib/musicality/notation/model/instrument.rb', line 40 def self.treble_bass name, midi_num, transpose_interval = 0 Instrument.new(name, [TREBLE,BASS], midi_num, transpose_interval) end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/musicality/notation/model/instrument.rb', line 21 def ==(other) begin return name == other.name && Set.new(clefs) == Set.new(other.clefs) && midi_num == other.midi_num && transpose_interval == other.transpose_interval rescue # if other object doesn't have the right methods return false end end |