Class: PosixProxy::CaseHandler

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

Instance Method Summary collapse

Constructor Details

#initialize(buffer) ⇒ CaseHandler

Returns a new instance of CaseHandler.



20
21
22
# File 'lib/shell-proxy/posix/case.rb', line 20

def initialize(buffer)
  @buffer = buffer
end

Instance Method Details

#__escapinate(v) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/shell-proxy/posix/case.rb', line 24

def __escapinate(v)
  if v.empty?
    '""'
  else
    v
  end
end

#when(opt, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/shell-proxy/posix/case.rb', line 32

def when(opt, &block)
  @buffer << "#{__escapinate(opt.to_s)})"
  @buffer.indent
  yield
  @buffer.undent
  @buffer << ";;"
end