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] License: Apache License, Version 2.0 Copyright: (C) 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

#black ⇒ Object



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

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

#blank? ⇒ Boolean

Strips out whitespace then tests if the string is empty.

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

Returns:

  • (Boolean)


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

#blue ⇒ Object



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

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

#bold ⇒ Object



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

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

#bright_red ⇒ Object



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

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

#clear ⇒ Object



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

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

#colorize(text, color_code) ⇒ Object



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

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

#concealed ⇒ Object



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

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

#cream ⇒ Object



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

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

#cyan ⇒ Object



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

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

#cyan2 ⇒ Object



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

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

#dark ⇒ Object



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

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

#erase_char ⇒ Object



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

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

#erase_line ⇒ Object



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

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

#gray ⇒ Object



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

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

#green ⇒ Object



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

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

#light_gray ⇒ Object



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

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

#magenta ⇒ Object



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

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

#mustard ⇒ Object



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

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

#olive ⇒ Object



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

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

#on_black ⇒ Object



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

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

#on_blue ⇒ Object



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

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

#on_cyan ⇒ Object



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

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

#on_green ⇒ Object



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

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

#on_magenta ⇒ Object



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

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

#on_red ⇒ Object



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

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

#on_white ⇒ Object



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

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

#on_yellow ⇒ Object



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

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

#orange ⇒ Object



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

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

#purple ⇒ Object



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

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

#red ⇒ Object



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

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

#reverse ⇒ Object



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

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

#underline ⇒ Object



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

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

#white ⇒ Object



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

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

#yellow ⇒ Object



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

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