Class: PryBot::StringIOProxy
- Includes:
- DRb::DRbUndumped
- Defined in:
- lib/io-string-proxy.rb
Overview
Class used to wrap modules so that they can be sent through DRb. This will mostly be used for Readline.
Instance Attribute Summary collapse
-
#completion_proc ⇒ Object
Returns the value of attribute completion_proc.
-
#obj ⇒ Object
Returns the value of attribute obj.
Instance Method Summary collapse
- #<<(data) ⇒ Object
-
#initialize(obj) ⇒ StringIOProxy
constructor
A new instance of StringIOProxy.
- #print(*objs) ⇒ Object
- #puts(*lines) ⇒ Object
- #readline(prompt = "") ⇒ Object
- #readlines ⇒ Object
- #string ⇒ Object
- #tty? ⇒ Boolean
- #write(data) ⇒ Object
Constructor Details
#initialize(obj) ⇒ StringIOProxy
Returns a new instance of StringIOProxy.
8 9 10 11 12 |
# File 'lib/io-string-proxy.rb', line 8 def initialize(obj) @stdout = $stdout @stdin = $stdin @obj = obj end |
Instance Attribute Details
#completion_proc ⇒ Object
Returns the value of attribute completion_proc.
20 21 22 |
# File 'lib/io-string-proxy.rb', line 20 def completion_proc @completion_proc end |
#obj ⇒ Object
Returns the value of attribute obj.
7 8 9 |
# File 'lib/io-string-proxy.rb', line 7 def obj @obj end |
Instance Method Details
#<<(data) ⇒ Object
48 49 50 51 |
# File 'lib/io-string-proxy.rb', line 48 def <<(data) @obj.string << data self end |
#print(*objs) ⇒ Object
40 41 42 |
# File 'lib/io-string-proxy.rb', line 40 def print(*objs) @obj.puts(*objs) end |
#puts(*lines) ⇒ Object
34 35 36 37 38 |
# File 'lib/io-string-proxy.rb', line 34 def puts(*lines) lines.map! {|line| line.end_with?("\n") ? line : line+"\n" } # @stdout.puts "STDOUT: #{lines.inspect}" lines.each { |l| self << l} end |
#readline(prompt = "") ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/io-string-proxy.rb', line 22 def readline(prompt="") begin @obj.readline() rescue EOFError "" end end |
#readlines ⇒ Object
57 58 59 60 61 62 |
# File 'lib/io-string-proxy.rb', line 57 def readlines pos = @obj.pos string = @obj.string[pos..-1] @obj.pos = @obj.size return string end |
#string ⇒ Object
30 31 32 |
# File 'lib/io-string-proxy.rb', line 30 def string() @obj.string end |
#tty? ⇒ Boolean
53 54 55 |
# File 'lib/io-string-proxy.rb', line 53 def tty? false end |
#write(data) ⇒ Object
44 45 46 |
# File 'lib/io-string-proxy.rb', line 44 def write(data) @obj.write data end |