Sha256: ba0cd6fa90d48227794fbe02ca8bd96b5cdd2c9f0f5882c32d54749f53430c5d
Contents?: true
Size: 815 Bytes
Versions: 6
Compression:
Stored size: 815 Bytes
Contents
class HeadMusic::Composition attr_reader :name, :key_signature, :meter, :bars, :voices def initialize(name: nil, key_signature: nil, meter: nil) ensure_attributes(name, key_signature, meter) add_bar add_voice end def add_bar add_bars(1) end def add_bars(number) @bars ||= [] number.times do @bars << HeadMusic::Bar.new(self) end end def add_voice @voices ||= [] @voices << HeadMusic::Voice.new(composition: self) end private def ensure_attributes(name, key_signature, meter) @name = name || 'Composition' @key_signature = HeadMusic::KeySignature.get(key_signature) if key_signature @key_signature ||= HeadMusic::KeySignature.default @meter = HeadMusic::Meter.get(meter) if meter @meter ||= HeadMusic::Meter.default end end
Version data entries
6 entries across 6 versions & 1 rubygems