Module: Rvm2::Ui::Output::Console::ConsoleIO
- Defined in:
- lib/plugins/rvm2/ui/output/console.rb
Instance Attribute Summary collapse
-
#was_new_line ⇒ Object
Returns the value of attribute was_new_line.
Instance Method Summary collapse
- #console_parent=(value) ⇒ Object
- #indent(string) ⇒ Object
- #levels ⇒ Object
- #winsize ⇒ Object
- #write(string) ⇒ Object
Instance Attribute Details
#was_new_line ⇒ Object
Returns the value of attribute was_new_line.
9 10 11 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 9 def was_new_line @was_new_line end |
Instance Method Details
#console_parent=(value) ⇒ Object
11 12 13 14 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 11 def console_parent=(value) @was_new_line = true @console_parent = value end |
#indent(string) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 22 def indent(string) if levels > 0 ends_with_n = string.end_with?("\n") string = string.split(/\n/).map do |s| s.sub(/^(\r?)/,"\\1#{" "*levels}") end.join("\n") string << "\n" if ends_with_n end string end |
#levels ⇒ Object
33 34 35 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 33 def levels @console_parent.levels end |
#winsize ⇒ Object
37 38 39 40 41 42 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 37 def winsize rows, columns = super [rows, columns - levels*2] rescue nil end |
#write(string) ⇒ Object
16 17 18 19 20 |
# File 'lib/plugins/rvm2/ui/output/console.rb', line 16 def write(string) super("\n") if !@was_new_line and !string.start_with?("\r") super(indent(string)) @was_new_line = true end |