Class: Bane::Behaviors::Responders::SlowResponse
- Inherits:
-
Object
- Object
- Bane::Behaviors::Responders::SlowResponse
- Defined in:
- lib/bane/behaviors/responders/slow_response.rb
Overview
Sends a fixed response character-by-character, pausing between each character.
Options:
- message: The response to send. Default: "Hello, world!"
- pause_duration: The number of seconds to pause between each character. Default: 10 seconds
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SlowResponse
constructor
A new instance of SlowResponse.
- #serve(io) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SlowResponse
Returns a new instance of SlowResponse.
13 14 15 |
# File 'lib/bane/behaviors/responders/slow_response.rb', line 13 def initialize( = {}) @options = {message: "Hello, world!", pause_duration: 10}.merge() end |
Instance Method Details
#serve(io) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/bane/behaviors/responders/slow_response.rb', line 17 def serve(io) = @options[:message] pause_duration = @options[:pause_duration] .each_char do |char| io.write char sleep pause_duration end end |