Class: String

Inherits:
Object show all
Defined in:
lib/hoodie/core_ext/blank.rb,
lib/hoodie/core_ext/string.rb

Overview

Author: Stefano Harding <[email protected]>

Copyright © 2014-2015 Stefano Harding

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Instance Method Summary collapse

Instance Method Details

#blackObject



30
# File 'lib/hoodie/core_ext/string.rb', line 30

def black;      colorize(self, "\e[0;30m"); end

#blank?TrueClass, FalseClass

Strips out whitespace then tests if the string is empty.

"".blank?         #=>  true
"     ".blank?    #=>  true
" hey ho ".blank? #=>  false

Returns:



105
106
107
# File 'lib/hoodie/core_ext/blank.rb', line 105

def blank?
  strip.empty?
end


27
# File 'lib/hoodie/core_ext/string.rb', line 27

def blink;      colorize(self, "\e[5m");    end

#blueObject



38
# File 'lib/hoodie/core_ext/string.rb', line 38

def blue;       colorize(self, "\e[0;34m"); end

#boldObject



24
# File 'lib/hoodie/core_ext/string.rb', line 24

def bold;       colorize(self, "\e[1m");    end

#clearObject



21
# File 'lib/hoodie/core_ext/string.rb', line 21

def clear;      colorize(self, "\e[0m");    end

#colorize(text, color_code) ⇒ Object



53
# File 'lib/hoodie/core_ext/string.rb', line 53

def colorize(text, color_code) "#{color_code}#{text}\e[0m" end

#concealedObject



29
# File 'lib/hoodie/core_ext/string.rb', line 29

def concealed;  colorize(self, "\e[8m");    end

#creamObject



37
# File 'lib/hoodie/core_ext/string.rb', line 37

def cream;      colorize(self, "\e[1;33m"); end

#cyanObject



42
# File 'lib/hoodie/core_ext/string.rb', line 42

def cyan;       colorize(self, "\e[0;36m"); end

#cyan2Object



43
# File 'lib/hoodie/core_ext/string.rb', line 43

def cyan2;      colorize(self, "\e[1;36m"); end

#darkObject



25
# File 'lib/hoodie/core_ext/string.rb', line 25

def dark;       colorize(self, "\e[2m");    end

#erase_charObject



23
# File 'lib/hoodie/core_ext/string.rb', line 23

def erase_char; colorize(self, "\e[P");     end

#erase_lineObject



22
# File 'lib/hoodie/core_ext/string.rb', line 22

def erase_line; colorize(self, "\e[K");     end

#grayObject



31
# File 'lib/hoodie/core_ext/string.rb', line 31

def gray;       colorize(self, "\e[1;30m"); end

#greenObject



34
# File 'lib/hoodie/core_ext/string.rb', line 34

def green;      colorize(self, "\e[0;32m"); end

#magentaObject



33
# File 'lib/hoodie/core_ext/string.rb', line 33

def magenta;    colorize(self, "\e[1;31m"); end

#mustardObject



41
# File 'lib/hoodie/core_ext/string.rb', line 41

def mustard;    colorize(self, "\e[1;35m"); end

#oliveObject



35
# File 'lib/hoodie/core_ext/string.rb', line 35

def olive;      colorize(self, "\e[1;32m"); end

#on_blackObject



45
# File 'lib/hoodie/core_ext/string.rb', line 45

def on_black;   colorize(self, "\e[40m");   end

#on_blueObject



49
# File 'lib/hoodie/core_ext/string.rb', line 49

def on_blue;    colorize(self, "\e[44m");   end

#on_cyanObject



51
# File 'lib/hoodie/core_ext/string.rb', line 51

def on_cyan;    colorize(self, "\e[46m");   end

#on_greenObject



47
# File 'lib/hoodie/core_ext/string.rb', line 47

def on_green;   colorize(self, "\e[42m");   end

#on_magentaObject



50
# File 'lib/hoodie/core_ext/string.rb', line 50

def on_magenta; colorize(self, "\e[45m");   end

#on_redObject



46
# File 'lib/hoodie/core_ext/string.rb', line 46

def on_red;     colorize(self, "\e[41m");   end

#on_whiteObject



52
# File 'lib/hoodie/core_ext/string.rb', line 52

def on_white;   colorize(self, "\e[47m");   end

#on_yellowObject



48
# File 'lib/hoodie/core_ext/string.rb', line 48

def on_yellow;  colorize(self, "\e[43m");   end

#orangeObject



40
# File 'lib/hoodie/core_ext/string.rb', line 40

def orange;     colorize(self, "\e[0;35m"); end

#purpleObject



39
# File 'lib/hoodie/core_ext/string.rb', line 39

def purple;     colorize(self, "\e[1;34m"); end

#redObject



32
# File 'lib/hoodie/core_ext/string.rb', line 32

def red;        colorize(self, "\e[0;31m"); end

#reverseObject



28
# File 'lib/hoodie/core_ext/string.rb', line 28

def reverse;    colorize(self, "\e[7m");    end

#underlineObject



26
# File 'lib/hoodie/core_ext/string.rb', line 26

def underline;  colorize(self, "\e[4m");    end

#whiteObject



44
# File 'lib/hoodie/core_ext/string.rb', line 44

def white;      colorize(self, "\e[0;97m"); end

#yellowObject



36
# File 'lib/hoodie/core_ext/string.rb', line 36

def yellow;     colorize(self, "\e[0;33m"); end