Sha256: 849a72c20425e95dd028f1f6d1ea01136bbf7d87fd2f8514a251f5e7a4da30db
Contents?: true
Size: 738 Bytes
Versions: 3
Compression:
Stored size: 738 Bytes
Contents
module Coltrane # It describes a interval between 2 pitches class Interval attr_reader :semitones NAMES = [ '1P', '2m', '2M', '3m', '3M', '4P', '4A', '5P', '6m', '6M', '7m', '7M' ].freeze def initialize(arg) @semitones = (case arg when Interval then arg.semitones when String then NAMES.index(arg) when Numeric then arg end) % 12 end def name NAMES[semitones] end def +(x) case x when Numeric then Interval.new(semitones + x) when Interval then Interval.new(semitones + x.semitones) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
coltrane-1.0.11 | lib/coltrane/interval.rb |
coltrane-1.0.1 | lib/coltrane/interval.rb |
coltrane-1.0.0 | lib/coltrane/interval.rb |