Sha256: 5a32442e3c05a0f259c2ece953e699168502746ef767d177dbb1765ed3be5e5b
Contents?: true
Size: 707 Bytes
Versions: 1
Compression:
Stored size: 707 Bytes
Contents
class HeadMusic::Accidental ACCIDENTAL_SEMITONES = { '#' => 1, '##' => 2, 'b' => -1, 'bb' => -2 } attr_reader :string def self.get(identifier) @accidentals ||= {} @accidentals[identifier] ||= for_symbol(identifier) || for_interval(identifier) end def self.for_symbol(identifier) new(identifier) if ACCIDENTAL_SEMITONES.keys.include?(identifier) end def self.for_interval(semitones) ACCIDENTAL_SEMITONES.key(semitones.to_i) end def initialize(string) @string = string end def to_s string end def ==(value) to_s == value.to_s end def semitones ACCIDENTAL_SEMITONES.fetch(string, 0) end private_class_method :new end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.1.1 | lib/head_music/accidental.rb |