Sha256: a35c1ae7d7e5d1502cd441b42687f47eaa2f7715758892029987c5e11396ad87
Contents?: true
Size: 827 Bytes
Versions: 1
Compression:
Stored size: 827 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) @voices = [] 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(role: nil) @voices << HeadMusic::Voice.new(composition: self, role: role) @voices.last 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.11.9 | lib/head_music/composition.rb |