Sha256: 8d35167af7abf415c4e4ca8481e9fc6b0a01b420c70ce7b25d4334a253f4661d
Contents?: true
Size: 1 KB
Versions: 5
Compression:
Stored size: 1 KB
Contents
module Music module Transcription class Change attr_accessor :value, :duration def initialize value, duration @value = value @duration = duration end def ==(other) self.class == other.class && self.value == other.value && self.duration == other.duration end class Immediate < Change include Validatable def initialize value @check_methods = [ :ensure_zero_duration ] super(value,0) end def ensure_zero_duration unless @duration == 0 raise NonZeroError, "immediate change duration #{self.duration} must be 0" end end end class Gradual < Change include Validatable def initialize value, transition_duration @check_methods = [ :ensure_nonnegative_duration ] super(value, transition_duration) end def ensure_nonnegative_duration if @duration < 0 raise NegativeError, "gradual change duration #{self.duration} must be non-negative" end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems