Class: Rvm2::Ui::Output::Console
- Inherits:
-
Object
- Object
- Rvm2::Ui::Output::Console
- Defined in:
- lib/plugins/rvm2/ui/output/console.rb
Direct Known Subclasses
Defined Under Namespace
Modules: ConsoleIO
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #finish(status) ⇒ Object
-
#initialize(rvm2_plugins, stdout = $stdout, stderr = $stderr) ⇒ Console
constructor
A new instance of Console.
- #levels ⇒ Object
- #log(message, type = :log) ⇒ Object
- #progress(type, *args) ⇒ Object
- #start(name) ⇒ Object
Constructor Details
#initialize(rvm2_plugins, stdout = $stdout, stderr = $stderr) ⇒ Console
Returns a new instance of Console.
51 52 53 54 55 56 57 58 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 51 def initialize(rvm2_plugins, stdout = $stdout, stderr = $stderr) @rvm2_plugins = rvm2_plugins @stdout = stdout.extend(ConsoleIO) @stdout.console_parent = self @stderr = stderr.extend(ConsoleIO) @stderr.console_parent = self @names = [] end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
45 46 47 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 45 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
45 46 47 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 45 def stdout @stdout end |
Instance Method Details
#finish(status) ⇒ Object
66 67 68 69 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 66 def finish(status) name = @names.pop @stdout.puts("\r#{(name, status ? "v" : "x")}") end |
#levels ⇒ Object
47 48 49 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 47 def levels @names.size end |
#log(message, type = :log) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 71 def log(, type = :log) case type when :log @stdout.puts() when :warn @stdout.puts("Warning: #{}") when :warn_important @stdout.puts("WARNING! #{}") when :error @stderr.puts("Error: #{}") else @stdout.puts("#{type.to_s.capitalize}: #{}") end end |
#progress(type, *args) ⇒ Object
86 87 88 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 86 def progress(type, *args) @rvm2_plugins.first_class!("ui/progress/console", type).new(@rvm2_plugins, self, *args) end |
#start(name) ⇒ Object
60 61 62 63 64 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 60 def start(name) @stdout.write((name, " ")) @stdout.was_new_line = false @names.push(name) end |