Sha256: 81d1d8f3e887c526ecde9bb3c0f154b6fd77798307b3afa49ed168e470dfd0aa

Contents?: true

Size: 664 Bytes

Versions: 22

Compression:

Stored size: 664 Bytes

Contents

# frozen_string_literal: true

module Coltrane
  module Representation
    class Guitar
      class String
        attr_reader :pitch, :guitar

        def initialize(pitch, guitar:)
          @guitar = guitar
          @pitch = pitch
        end

        def find(pitch_class, possible_frets: (0..guitar.frets).to_a)
          output = []
          n = 0
          loop do
            f = (pitch_class.integer - pitch.integer) % 12 + 12 * n
            possible_frets.include?(f) ? output << Note.new(self, f) : break
            n += 1
          end
          output
        end

        def +(fret)
          pitch + fret
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
coltrane-4.1.2 lib/coltrane/representation/guitar/string.rb
coltrane-4.1.1 lib/coltrane/representation/guitar/string.rb
coltrane-4.1.0 lib/coltrane/representation/guitar/string.rb
coltrane-4.0.6 lib/coltrane/representation/guitar/string.rb
coltrane-4.0.5 lib/coltrane/representation/guitar/string.rb
coltrane-4.0.4 lib/coltrane/representation/guitar/string.rb
coltrane-4.0.3 lib/coltrane/representation/guitar/string.rb
coltrane-3.4.2 lib/coltrane/representation/guitar/string.rb
coltrane-3.4.1 lib/coltrane/representation/guitar/string.rb
coltrane-3.4.0 lib/coltrane/representation/guitar/string.rb
coltrane-3.3.3 lib/coltrane/representation/guitar/string.rb
coltrane-3.3.2 lib/coltrane/representation/guitar/string.rb
coltrane-3.3.1 lib/coltrane/representation/guitar/string.rb
coltrane-3.3.0 lib/coltrane/representation/guitar/string.rb
coltrane-3.2.0 lib/coltrane/representation/guitar/string.rb
coltrane-3.1.3 lib/coltrane/representation/guitar/string.rb
coltrane-3.1.2 lib/coltrane/representation/guitar/string.rb
coltrane-3.1.1 lib/coltrane/representation/guitar/string.rb
coltrane-3.1.0 lib/coltrane/representation/guitar/string.rb
coltrane-3.0.0 lib/coltrane/representation/guitar/string.rb