Class: CmdBuffer
- Inherits:
-
Object
- Object
- CmdBuffer
- Defined in:
- lib/shell-proxy/cmd_buffer.rb
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #indent ⇒ Object
-
#initialize ⇒ CmdBuffer
constructor
A new instance of CmdBuffer.
- #pop ⇒ Object
- #undent ⇒ Object
- #write(buf) ⇒ Object
Constructor Details
#initialize ⇒ CmdBuffer
Returns a new instance of CmdBuffer.
2 3 4 5 |
# File 'lib/shell-proxy/cmd_buffer.rb', line 2 def initialize @indent = 0 @buffer = [] end |
Instance Method Details
#<<(other) ⇒ Object
15 16 17 |
# File 'lib/shell-proxy/cmd_buffer.rb', line 15 def << (other) @buffer << "#{INDENT_PADDING * @indent}#{other}" end |
#indent ⇒ Object
7 8 9 |
# File 'lib/shell-proxy/cmd_buffer.rb', line 7 def indent @indent += 1 end |
#pop ⇒ Object
19 20 21 |
# File 'lib/shell-proxy/cmd_buffer.rb', line 19 def pop @buffer.pop end |
#undent ⇒ Object
11 12 13 |
# File 'lib/shell-proxy/cmd_buffer.rb', line 11 def undent @indent -= 1 end |
#write(buf) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/shell-proxy/cmd_buffer.rb', line 23 def write(buf) @buffer.each do |l| buf.puts l end buf.flush end |