Class: String
- 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
- #black ⇒ Object
-
#blank? ⇒ TrueClass, FalseClass
Strips out whitespace then tests if the string is empty.
- #blink ⇒ Object
- #blue ⇒ Object
- #bold ⇒ Object
- #clear ⇒ Object
- #colorize(text, color_code) ⇒ Object
- #concealed ⇒ Object
- #cream ⇒ Object
- #cyan ⇒ Object
- #cyan2 ⇒ Object
- #dark ⇒ Object
- #erase_char ⇒ Object
- #erase_line ⇒ Object
- #gray ⇒ Object
- #green ⇒ Object
- #magenta ⇒ Object
- #mustard ⇒ Object
- #olive ⇒ Object
- #on_black ⇒ Object
- #on_blue ⇒ Object
- #on_cyan ⇒ Object
- #on_green ⇒ Object
- #on_magenta ⇒ Object
- #on_red ⇒ Object
- #on_white ⇒ Object
- #on_yellow ⇒ Object
- #orange ⇒ Object
- #purple ⇒ Object
- #red ⇒ Object
- #reverse ⇒ Object
- #underline ⇒ Object
- #white ⇒ Object
- #yellow ⇒ Object
Instance Method Details
#black ⇒ Object
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
105 106 107 |
# File 'lib/hoodie/core_ext/blank.rb', line 105 def blank? strip.empty? end |
#blink ⇒ Object
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 |
#clear ⇒ Object
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 |
#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 |
#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
45 |
# File 'lib/hoodie/core_ext/string.rb', line 45 def on_black; colorize(self, "\e[40m"); end |
#on_blue ⇒ Object
49 |
# File 'lib/hoodie/core_ext/string.rb', line 49 def on_blue; colorize(self, "\e[44m"); end |
#on_cyan ⇒ Object
51 |
# File 'lib/hoodie/core_ext/string.rb', line 51 def on_cyan; colorize(self, "\e[46m"); end |
#on_green ⇒ Object
47 |
# File 'lib/hoodie/core_ext/string.rb', line 47 def on_green; colorize(self, "\e[42m"); end |
#on_magenta ⇒ Object
50 |
# File 'lib/hoodie/core_ext/string.rb', line 50 def on_magenta; colorize(self, "\e[45m"); end |
#on_red ⇒ Object
46 |
# File 'lib/hoodie/core_ext/string.rb', line 46 def on_red; colorize(self, "\e[41m"); end |
#on_white ⇒ Object
52 |
# File 'lib/hoodie/core_ext/string.rb', line 52 def on_white; colorize(self, "\e[47m"); end |
#on_yellow ⇒ Object
48 |
# File 'lib/hoodie/core_ext/string.rb', line 48 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
44 |
# File 'lib/hoodie/core_ext/string.rb', line 44 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 |