Class: Clef::Core::Tempo

Inherits:
Object
  • Object
show all
Defined in:
lib/clef/core/tempo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(beat_unit:, bpm:) ⇒ Tempo

Returns a new instance of Tempo.

Parameters:

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
# File 'lib/clef/core/tempo.rb', line 10

def initialize(beat_unit:, bpm:)
  raise ArgumentError, "beat_unit must be a Clef::Core::Duration" unless beat_unit.is_a?(Duration)
  raise ArgumentError, "bpm must be a positive Integer" unless bpm.is_a?(Integer) && bpm.positive?

  @beat_unit = beat_unit
  @bpm = bpm
end

Instance Attribute Details

#beat_unitObject (readonly)

Returns the value of attribute beat_unit.



6
7
8
# File 'lib/clef/core/tempo.rb', line 6

def beat_unit
  @beat_unit
end

#bpmObject (readonly)

Returns the value of attribute bpm.



6
7
8
# File 'lib/clef/core/tempo.rb', line 6

def bpm
  @bpm
end

Instance Method Details

#lengthRational

Returns:

  • (Rational)


19
20
21
# File 'lib/clef/core/tempo.rb', line 19

def length
  Rational(0, 1)
end