Class: Miserable

Inherits:
Object
  • Object
show all
Defined in:
lib/miserable.rb

Overview

Convert BPM (beats-per-minute) to millisecond

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bpm) ⇒ Miserable

Returns a new instance of Miserable.



9
10
11
# File 'lib/miserable.rb', line 9

def initialize(bpm)
  @quarter_note = (((60 / bpm.to_f) * 1000) * 100_000) / 100_000
end

Instance Attribute Details

#quarter_noteObject (readonly)

Returns the value of attribute quarter_note.



7
8
9
# File 'lib/miserable.rb', line 7

def quarter_note
  @quarter_note
end

Instance Method Details

#eighth_noteObject



21
22
23
# File 'lib/miserable.rb', line 21

def eighth_note
  @quarter_note / 2
end

#half_noteObject



17
18
19
# File 'lib/miserable.rb', line 17

def half_note
  @quarter_note * 2
end

#sixteenth_noteObject



25
26
27
# File 'lib/miserable.rb', line 25

def sixteenth_note
  @quarter_note / 4
end

#sixth_noteObject



37
38
39
# File 'lib/miserable.rb', line 37

def sixth_note
  whole_note / 6
end

#sixtyfourth_noteObject



33
34
35
# File 'lib/miserable.rb', line 33

def sixtyfourth_note
  @quarter_note / 16
end

#thirtysecond_noteObject



29
30
31
# File 'lib/miserable.rb', line 29

def thirtysecond_note
  @quarter_note / 8
end

#whole_noteObject



13
14
15
# File 'lib/miserable.rb', line 13

def whole_note
  @quarter_note * 4
end