Class: ESI::OutputAdapter
- Inherits:
-
Object
- Object
- ESI::OutputAdapter
- Defined in:
- lib/esi/response.rb
Overview
this class allows me to write, <<, or call an object to send it bytes, priority being <<, then write, then call
Instance Attribute Summary collapse
-
#device ⇒ Object
readonly
Returns the value of attribute device.
Instance Method Summary collapse
-
#initialize(output_device) ⇒ OutputAdapter
constructor
A new instance of OutputAdapter.
Constructor Details
#initialize(output_device) ⇒ OutputAdapter
Returns a new instance of OutputAdapter.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/esi/response.rb', line 12 def initialize(output_device) @device = output_device if @device.respond_to?(:<<) self.instance_eval do def << (msg) @device << msg end end elsif @device.respond_to?(:write) self.instance_eval do def << (msg) @device.write msg end end elsif @device.respond_to?(:call) self.instance_eval do def << (msg) @device.call msg end end end end |
Instance Attribute Details
#device ⇒ Object (readonly)
Returns the value of attribute device.
11 12 13 |
# File 'lib/esi/response.rb', line 11 def device @device end |