Sha256: fd600d8ea8380650aeea08b5d71b09cf4e6e18d88df165c6205fbec8c84d47d8

Contents?: true

Size: 535 Bytes

Versions: 1

Compression:

Stored size: 535 Bytes

Contents

module Music
module Transcription

class Tempo
  attr_reader :value
  def initialize value
    raise NonPositiveError, "Given tempo value #{value} is not positive" if value <= 0
    @value = value
  end
  
  def ==(other)
    self.class == other.class && self.value == other.value
  end
  
  [ :qnpm, :bpm, :npm, :nps ].each do |sym|
    klass = Class.new(Tempo) do
      def to_s
        "#{@value}#{self.class::PRINT_SYM}"
      end
    end
    klass.const_set(:PRINT_SYM,sym)
    Tempo.const_set(sym.upcase,klass)
  end
end

end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
music-transcription-0.19.0 lib/music-transcription/model/tempo.rb