Class: CmdBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/shell-proxy/cmd_buffer.rb

Instance Method Summary collapse

Constructor Details

#initializeCmdBuffer

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

#indentObject



7
8
9
# File 'lib/shell-proxy/cmd_buffer.rb', line 7

def indent
  @indent += 1
end

#popObject



19
20
21
# File 'lib/shell-proxy/cmd_buffer.rb', line 19

def pop
  @buffer.pop
end

#undentObject



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