Class: Async::Container::Channel
- Inherits:
-
Object
- Object
- Async::Container::Channel
- Defined in:
- lib/async/container/channel.rb
Instance Attribute Summary collapse
-
#in ⇒ Object
readonly
Returns the value of attribute in.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
Instance Method Summary collapse
- #close ⇒ Object
- #close_read ⇒ Object
- #close_write ⇒ Object
-
#initialize ⇒ Channel
constructor
A new instance of Channel.
- #receive ⇒ Object
Constructor Details
#initialize ⇒ Channel
Returns a new instance of Channel.
26 27 28 |
# File 'lib/async/container/channel.rb', line 26 def initialize @in, @out = ::IO.pipe end |
Instance Attribute Details
#in ⇒ Object (readonly)
Returns the value of attribute in.
30 31 32 |
# File 'lib/async/container/channel.rb', line 30 def in @in end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
31 32 33 |
# File 'lib/async/container/channel.rb', line 31 def out @out end |
Instance Method Details
#close ⇒ Object
41 42 43 44 |
# File 'lib/async/container/channel.rb', line 41 def close close_read close_write end |
#close_read ⇒ Object
33 34 35 |
# File 'lib/async/container/channel.rb', line 33 def close_read @in.close end |
#close_write ⇒ Object
37 38 39 |
# File 'lib/async/container/channel.rb', line 37 def close_write @out.close end |
#receive ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/async/container/channel.rb', line 46 def receive if data = @in.gets begin return JSON.parse(data, symbolize_names: true) rescue return {line: data} end end end |