Class: Pedalboard::Components::Pedal
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Pedalboard::Components::Pedal
- Defined in:
- lib/pedalboard/components/pedal.rb
Constant Summary collapse
- LONG_TIME =
0.4
Instance Attribute Summary collapse
-
#long_press ⇒ Object
readonly
Returns the value of attribute long_press.
-
#press ⇒ Object
readonly
Returns the value of attribute press.
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #configure_dino_component ⇒ Object
-
#initialize(opts = {}) ⇒ Pedal
constructor
A new instance of Pedal.
Constructor Details
#initialize(opts = {}) ⇒ Pedal
Returns a new instance of Pedal.
12 13 14 15 16 17 18 19 |
# File 'lib/pedalboard/components/pedal.rb', line 12 def initialize opts={} super opts @press = opts.fetch(:press) { ->{} } @long_press = opts.fetch(:long_press) { ->{} } configure_dino_component end |
Instance Attribute Details
#long_press ⇒ Object (readonly)
Returns the value of attribute long_press.
10 11 12 |
# File 'lib/pedalboard/components/pedal.rb', line 10 def long_press @long_press end |
#press ⇒ Object (readonly)
Returns the value of attribute press.
10 11 12 |
# File 'lib/pedalboard/components/pedal.rb', line 10 def press @press end |
Instance Method Details
#configure_dino_component ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pedalboard/components/pedal.rb', line 21 def configure_dino_component dino_component.down do begin @start_time = Time.now rescue Exception => e puts e. end end dino_component.up do begin interval = Time.now - @start_time if interval > LONG_TIME run_command long_press else run_command press end rescue Exception => e puts e. end end end |