Class: Loguse::Shell
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#s ⇒ Object
Returns the value of attribute s.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(host, port) ⇒ Shell
constructor
A new instance of Shell.
- #open? ⇒ Boolean
- #run ⇒ Object
Constructor Details
#initialize(host, port) ⇒ Shell
Returns a new instance of Shell.
12 13 14 15 16 17 18 |
# File 'lib/loguse/shell.rb', line 12 def initialize(host, port) @host = host @port = port @s = nil self.async.run end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/loguse/shell.rb', line 8 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
9 10 11 |
# File 'lib/loguse/shell.rb', line 9 def port @port end |
#s ⇒ Object
Returns the value of attribute s.
10 11 12 |
# File 'lib/loguse/shell.rb', line 10 def s @s end |
Instance Method Details
#close ⇒ Object
43 44 45 |
# File 'lib/loguse/shell.rb', line 43 def close @s.close end |
#open? ⇒ Boolean
47 48 49 |
# File 'lib/loguse/shell.rb', line 47 def open? @s && !@s.closed? end |
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/loguse/shell.rb', line 20 def run t = Thread.new { begin @s = TCPSocket.open @host, @port @s.print "$~" while line = s.gets begin @s.puts `#{line.chomp}` @s.print "$~" rescue @s.print "Invalid Command..." end end close rescue end } t.join end |