Class: Charosc::Oscillator
- Inherits:
-
Object
- Object
- Charosc::Oscillator
- Defined in:
- lib/charosc/oscillator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, options = {}) ⇒ Oscillator
constructor
A new instance of Oscillator.
-
#next ⇒ Object
Public: Get the next value.
Constructor Details
#initialize(value, options = {}) ⇒ Oscillator
Returns a new instance of Oscillator.
5 6 7 8 9 |
# File 'lib/charosc/oscillator.rb', line 5 def initialize(value, = {}) @value = value @options = .merge() @direction = :up end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/charosc/oscillator.rb', line 3 def @options end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/charosc/oscillator.rb', line 3 def value @value end |
Instance Method Details
#next ⇒ Object
Public: Get the next value
Returns Integer
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/charosc/oscillator.rb', line 14 def next if at_top? @direction = :down elsif at_bottom? @direction = :up end go_up if going_up? go_down if going_down? value.round end |