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.



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

#levelsObject



33
34
35
# File 'lib/plugins/rvm2/ui/output/console.rb', line 33

def levels
  @console_parent.levels
end

#winsizeObject



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