Class: Tetsujin::Instrument::Guitar::String
- Inherits:
-
Object
- Object
- Tetsujin::Instrument::Guitar::String
- Defined in:
- lib/tetsujin/instrument/guitar/string.rb
Instance Attribute Summary collapse
-
#fretboard_length ⇒ Object
readonly
Returns the value of attribute fretboard_length.
-
#string_number ⇒ Object
readonly
Returns the value of attribute string_number.
-
#tuning ⇒ Object
readonly
Returns the value of attribute tuning.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #[](fret_number) ⇒ Tetsujin::Instrument::Guitar::Fret
- #frets ⇒ Tetsujin::Instrument::Guitar::Frets
-
#initialize(tuning:, string_number:, fretboard_length: 22) ⇒ String
constructor
A new instance of String.
- #play!(notes) ⇒ void
- #press!(fret_number) ⇒ void
- #release! ⇒ void
Constructor Details
#initialize(tuning:, string_number:, fretboard_length: 22) ⇒ String
Returns a new instance of String.
10 11 12 13 14 15 16 17 18 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 10 def initialize(tuning:, string_number:, fretboard_length: 22) raise TypeError unless tuning.is_a?(Tetsujin::Theory::Note) raise TypeError unless string_number.is_a?(Integer) raise TypeError unless fretboard_length.is_a?(Integer) @tuning = tuning @string_number = string_number @fretboard_length = fretboard_length end |
Instance Attribute Details
#fretboard_length ⇒ Object (readonly)
Returns the value of attribute fretboard_length.
5 6 7 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 5 def fretboard_length @fretboard_length end |
#string_number ⇒ Object (readonly)
Returns the value of attribute string_number.
5 6 7 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 5 def string_number @string_number end |
#tuning ⇒ Object (readonly)
Returns the value of attribute tuning.
5 6 7 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 5 def tuning @tuning end |
Instance Method Details
#==(other) ⇒ Boolean
50 51 52 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 50 def ==(other) tuning == other.tuning && string_number == other.string_number && fretboard_length == other.fretboard_length end |
#[](fret_number) ⇒ Tetsujin::Instrument::Guitar::Fret
27 28 29 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 27 def [](fret_number) frets.find_by_fret_number(fret_number) end |
#frets ⇒ Tetsujin::Instrument::Guitar::Frets
21 22 23 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 21 def frets @_frets ||= generate_frets end |
#play!(notes) ⇒ void
This method returns an undefined value.
33 34 35 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 33 def play!(notes) notes.each { |note| frets.play!(note) } end |
#press!(fret_number) ⇒ void
This method returns an undefined value.
39 40 41 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 39 def press!(fret_number) frets.press!(fret_number) end |
#release! ⇒ void
This method returns an undefined value.
44 45 46 |
# File 'lib/tetsujin/instrument/guitar/string.rb', line 44 def release! frets.release! end |