class Rvm2::Ui::Multi
Attributes
handlers[R]
Public Class Methods
new(rvm2_plugins = nil)
click to toggle source
# File lib/rvm2/ui/multi.rb, line 7 def initialize(rvm2_plugins = nil) @rvm2_plugins = rvm2_plugins || Pluginator.find("rvm2", extends: [:first_class]) @handlers = [] end
Public Instance Methods
add(handler, *args)
click to toggle source
# File lib/rvm2/ui/multi.rb, line 12 def add(handler, *args) @handlers << @rvm2_plugins.first_class!('ui/output', handler).new(@rvm2_plugins, *args) end
command(name, &block)
click to toggle source
ui.command “message” { do_something; }
# File lib/rvm2/ui/multi.rb, line 27 def command(name, &block) raise "No block given" unless block_given? @handlers.each {|h| h.start(name) } status = block.call @handlers.each {|h| h.finish(status) } status end
log(message, type = :log)
click to toggle source
ui.log ‘message’ ui.log ‘message’, :important standard types => :log, :warn, :important, :error in case unsupported type is used :log will be used
# File lib/rvm2/ui/multi.rb, line 39 def log(message, type = :log) @handlers.each {|h| h.log(message, type) } end
remove()
click to toggle source
# File lib/rvm2/ui/multi.rb, line 16 def remove @handlers.pop end
stderr()
click to toggle source
# File lib/rvm2/ui/multi.rb, line 47 def stderr @stderr ||= IoWriteRouter.new(self, :stderr) end
stdout()
click to toggle source
# File lib/rvm2/ui/multi.rb, line 43 def stdout @stdout ||= IoWriteRouter.new(self, :stdout) end
with(handler, *args, &block)
click to toggle source
# File lib/rvm2/ui/multi.rb, line 20 def with(handler, *args, &block) add(handler, *args) block.call remove end