Class: Tapout::Utility
- Inherits:
-
Object
- Object
- Tapout::Utility
- Defined in:
- lib/tapout/utility.rb
Overview
Provides some convenience methods for programs using tapout for testing. Be sure to require this script to use it, e.g. in ‘test_helper.rb`
require 'tapout/utility'
Instance Method Summary collapse
-
#initialize(output = STDOUT) ⇒ Utility
constructor
Initialize new Utility instance.
-
#pause ⇒ Object
Pause tapout processing.
-
#pry(binding) ⇒ Object
When using binding.pry while testing with tapout, it is best to tell tapout to pause processing first.
-
#resume ⇒ Object
Resume tapout processing.
Constructor Details
#initialize(output = STDOUT) ⇒ Utility
Initialize new Utility instance.
input - An input I/O, defaults to STDOUT>
15 16 17 |
# File 'lib/tapout/utility.rb', line 15 def initialize(output=STDOUT) @output = output end |
Instance Method Details
#pause ⇒ Object
Pause tapout processing. This method sends a ‘16.chr` signal to the output.
If a block is given, the block will be called after the pause. Then the block finishes, processing with be automatically resumed.
taoput.pause do
binding.pry
end
29 30 31 32 33 34 35 |
# File 'lib/tapout/utility.rb', line 29 def pause @output.puts 16.chr if block_given? yield resume end end |
#pry(binding) ⇒ Object
When using binding.pry while testing with tapout, it is best to tell tapout to pause processing first. This method provides a shortcut for doing exactly with pry.
Instead of:
binding.pry
use
tapout.pry(binding)
55 56 57 58 59 |
# File 'lib/tapout/utility.rb', line 55 def pry(binding) pause binding.pry resume end |
#resume ⇒ Object
Resume tapout processing. This method sends a ‘23.chr` signal to the output.
39 40 41 |
# File 'lib/tapout/utility.rb', line 39 def resume @output.puts 23.chr end |