Class: Rendezvous
- Inherits:
-
Object
- Object
- Rendezvous
- Defined in:
- lib/rendezvous.rb,
lib/rendezvous/version.rb
Defined Under Namespace
Modules: Errors
Constant Summary collapse
- DEFAULT_CHUNK_SIZE =
1 megabyte
1048576
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#activity_timeout ⇒ Object
readonly
Returns the value of attribute activity_timeout.
-
#connect_timeout ⇒ Object
readonly
Returns the value of attribute connect_timeout.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Rendezvous
constructor
A new instance of Rendezvous.
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Rendezvous
Returns a new instance of Rendezvous.
30 31 32 33 34 35 36 |
# File 'lib/rendezvous.rb', line 30 def initialize(={}) @activity_timeout = [:activity_timeout] @connect_timeout = [:connect_timeout] || 120 @input = [:input] || $stdin @output = [:output] || $stdout @url = [:url] end |
Instance Attribute Details
#activity_timeout ⇒ Object (readonly)
Returns the value of attribute activity_timeout.
23 24 25 |
# File 'lib/rendezvous.rb', line 23 def activity_timeout @activity_timeout end |
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
23 24 25 |
# File 'lib/rendezvous.rb', line 23 def connect_timeout @connect_timeout end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
23 24 25 |
# File 'lib/rendezvous.rb', line 23 def input @input end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
23 24 25 |
# File 'lib/rendezvous.rb', line 23 def output @output end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
23 24 25 |
# File 'lib/rendezvous.rb', line 23 def url @url end |
Class Method Details
.start(options = {}) ⇒ Object
25 26 27 28 |
# File 'lib/rendezvous.rb', line 25 def self.start(={}) rendezvous = self.new() rendezvous.start end |
Instance Method Details
#start ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rendezvous.rb', line 38 def start begin `stty -icanon -echo` if input.isatty loop do if selected = IO.select([socket, input], nil, nil, activity_timeout) if selected.first.first == input socket.write(input.readpartial(DEFAULT_CHUNK_SIZE)) socket.flush else output.write(socket.readpartial(DEFAULT_CHUNK_SIZE)) end else raise Rendezvous::Errors::ActivityTimeout end end rescue EOFError, Errno::EIO rescue Interrupt socket.write(3.chr) socket.flush retry rescue SignalException => e if Signal.list["QUIT"] == e.signo socket.write(28.chr) socket.flush retry end raise ensure `stty icanon echo` if input.isatty end end |