-
Notifications
You must be signed in to change notification settings - Fork 0
/
guitar.rb
43 lines (36 loc) · 865 Bytes
/
guitar.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true
module Blues
class Guitar
attr_reader :strings, :amplifier
def initialize(amplifier: nil)
@strings = Array.new(6) { |i| GuitarString.new(number: i + 1) }
@amplifier = amplifier
end
def pick(string:, fret:, duration: 0.25)
positioning = FingerPosition.new(
string: @strings[string - 1],
fret: fret,
duration: duration,
)
if @amplifier
@amplifier.amplify(positioning.note)
else
positioning
end
end
def tune(tuning = :standard)
Tuner.new(self).tune(tuning)
end
def restring(gauge_set:)
@strings = Array.new(6) do |i|
GuitarString.new(
number: i + 1,
gauge_set: gauge_set,
)
end
end
def plug_in(amplifier:)
@amplifier = amplifier
end
end
end