Class: Webmidi::Middleware::Recorder
- Defined in:
- lib/webmidi/middleware/recorder.rb
Defined Under Namespace
Classes: Tape
Instance Attribute Summary collapse
-
#tape ⇒ Object
readonly
Returns the value of attribute tape.
Instance Method Summary collapse
- #call(message) ⇒ Object
-
#initialize(app = nil, **options) ⇒ Recorder
constructor
A new instance of Recorder.
- #record ⇒ Object
- #recording? ⇒ Boolean
- #stop ⇒ Object
Constructor Details
Instance Attribute Details
#tape ⇒ Object (readonly)
Returns the value of attribute tape.
6 7 8 |
# File 'lib/webmidi/middleware/recorder.rb', line 6 def tape @tape end |
Instance Method Details
#call(message) ⇒ Object
15 16 17 18 19 |
# File 'lib/webmidi/middleware/recorder.rb', line 15 def call() tape = @mutex.synchronize { @recording ? @tape : nil } tape&.add() @app.call() end |
#record ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webmidi/middleware/recorder.rb', line 21 def record @mutex.synchronize do @tape = Tape.new @recording = true end if block_given? begin yield ensure @mutex.synchronize { @recording = false } end end @mutex.synchronize { @tape } end |
#recording? ⇒ Boolean
43 44 45 |
# File 'lib/webmidi/middleware/recorder.rb', line 43 def recording? @mutex.synchronize { @recording } end |
#stop ⇒ Object
36 37 38 39 40 41 |
# File 'lib/webmidi/middleware/recorder.rb', line 36 def stop @mutex.synchronize do @recording = false @tape end end |