Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/command_parser.rb,
lib/one_helper/onevm_helper.rb

Overview

colored strings

Instance Method Summary collapse

Instance Method Details

#greenObject



44
45
46
# File 'lib/one_helper/onevm_helper.rb', line 44

def green
    colorize(32)
end

#redObject



40
41
42
# File 'lib/one_helper/onevm_helper.rb', line 40

def red
    colorize(31)
end

#unindent(spaces = nil) ⇒ Object

Unindent the string by removing leading spaces.

Parameters:

  • spaces (Integer) (defaults to: nil)

    to remove, if nil the size of the first match of leading spaces is used.



26
27
28
29
30
31
32
33
# File 'lib/command_parser.rb', line 26

def unindent(spaces = nil)
    unless spaces
        m = match(/^(\s*)/)
        spaces = m[1].size
    end

    gsub!(/^ {#{spaces}}/, '')
end