Class: Miserable
- Inherits:
-
Object
- Object
- Miserable
- Defined in:
- lib/miserable.rb
Overview
Convert BPM (beats-per-minute) to millisecond
Instance Attribute Summary collapse
-
#quarter_note ⇒ Object
readonly
Returns the value of attribute quarter_note.
Instance Method Summary collapse
- #eighth_note ⇒ Object
- #half_note ⇒ Object
-
#initialize(bpm) ⇒ Miserable
constructor
A new instance of Miserable.
- #sixteenth_note ⇒ Object
- #sixth_note ⇒ Object
- #sixtyfourth_note ⇒ Object
- #thirtysecond_note ⇒ Object
- #whole_note ⇒ Object
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_note ⇒ Object (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_note ⇒ Object
21 22 23 |
# File 'lib/miserable.rb', line 21 def eighth_note @quarter_note / 2 end |
#half_note ⇒ Object
17 18 19 |
# File 'lib/miserable.rb', line 17 def half_note @quarter_note * 2 end |
#sixteenth_note ⇒ Object
25 26 27 |
# File 'lib/miserable.rb', line 25 def sixteenth_note @quarter_note / 4 end |
#sixth_note ⇒ Object
37 38 39 |
# File 'lib/miserable.rb', line 37 def sixth_note whole_note / 6 end |
#sixtyfourth_note ⇒ Object
33 34 35 |
# File 'lib/miserable.rb', line 33 def sixtyfourth_note @quarter_note / 16 end |
#thirtysecond_note ⇒ Object
29 30 31 |
# File 'lib/miserable.rb', line 29 def thirtysecond_note @quarter_note / 8 end |
#whole_note ⇒ Object
13 14 15 |
# File 'lib/miserable.rb', line 13 def whole_note @quarter_note * 4 end |