Module: Rvm2::Ui::Output::Console::ConsoleIO

Defined in:
lib/plugins/rvm2/ui/output/console.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#was_new_lineObject

Returns the value of attribute was_new_line.



7
8
9
# File 'lib/plugins/rvm2/ui/output/console.rb', line 7

def was_new_line
  @was_new_line
end

Instance Method Details

#console_parent=(value) ⇒ Object



9
10
11
12
# File 'lib/plugins/rvm2/ui/output/console.rb', line 9

def console_parent=(value)
  @was_new_line = true
  @console_parent = value
end

#indent(string) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/plugins/rvm2/ui/output/console.rb', line 20

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

#levelsObject



31
32
33
# File 'lib/plugins/rvm2/ui/output/console.rb', line 31

def levels
  @console_parent.levels
end

#write(string) ⇒ Object



14
15
16
17
18
# File 'lib/plugins/rvm2/ui/output/console.rb', line 14

def write(string)
  super("\n") if !@was_new_line and !string.start_with?("\r")
  super(indent(string))
  @was_new_line = true
end