Class: OptparseLite::Ui

Inherits:
Object
  • Object
show all
Defined in:
lib/optparse-lite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeUi

Returns a new instance of Ui.



625
626
627
628
# File 'lib/optparse-lite.rb', line 625

def initialize
  @out = $stdout
  @err = $stderr
end

Instance Attribute Details

#errObject

Returns the value of attribute err.



629
630
631
# File 'lib/optparse-lite.rb', line 629

def err
  @err
end

Instance Method Details

#pop(both = false) ⇒ Object



641
642
643
644
645
646
647
# File 'lib/optparse-lite.rb', line 641

def pop both=false
  ret = [@out, @err]
  @out, @err = @stack.pop
  return ret if both
  return ret[0] if ret[1].respond_to?(:to_str) && ''==ret[1].to_str
  # ret # ick. tries to pretend there is only one out stream when possible
end

#push(out = Sio.new, err = Sio.new) ⇒ Object



635
636
637
638
639
# File 'lib/optparse-lite.rb', line 635

def push out=Sio.new, err=Sio.new
  @stack ||= []
  @stack.push [@out, @err]
  @out, @err = out, err
end