Class: String
Instance Method Summary collapse
-
#alnum? ⇒ Boolean
Self test alphanum String class.
-
#alpha? ⇒ Boolean
Self test alpha String class.
-
#decrypt(key) ⇒ Object
Decrypt a string using a key.
-
#encrypt(key) ⇒ Object
Encrypt a string using a key.
-
#fix(size, pattern = ' ') ⇒ Object
Justity relative left or right position filled with a espefific char in String.
-
#nil? ⇒ Boolean
Self test nil String class.
Instance Method Details
#alnum? ⇒ Boolean
Self test alphanum String class.
256 257 258 |
# File 'lib/lib/utils.rb', line 256 def alnum? !!match(/^[[:alnum:]]+$/) end |
#alpha? ⇒ Boolean
Self test alpha String class.
263 264 265 |
# File 'lib/lib/utils.rb', line 263 def alpha? !!match(/^[[:alpha:]]+$/) end |
#decrypt(key) ⇒ Object
Decrypt a string using a key. sample msg = "teste do encrypt".light_blue passwd = 'tools999' encrypted = msg.encrypt passwd puts (encrypted.decrypt passwd)
249 250 251 |
# File 'lib/lib/utils.rb', line 249 def decrypt(key) Encrypt.load self, key end |
#encrypt(key) ⇒ Object
Encrypt a string using a key. sample msg = "teste do encrypt".light_blue passwd = 'tools999' encrypted = msg.encrypt passwd puts (encrypted.decrypt passwd)
238 239 240 |
# File 'lib/lib/utils.rb', line 238 def encrypt(key) Encrypt.dump self, key end |
#fix(size, pattern = ' ') ⇒ Object
Justity relative left or right position filled with a espefific char in String.
sample:
"TESTE".fix(10,'xy') # => xxxxxTESTE "TESTE".fix(-10,'xy') # => TESTExxxxx
222 223 224 225 226 227 228 229 |
# File 'lib/lib/utils.rb', line 222 def fix(size, pattern=' ') if size >= 0 self[0...size].rjust(size, pattern) else diff = size.abs - self.size self + ''.fix(diff,pattern) end end |
#nil? ⇒ Boolean
Self test nil String class.
207 208 209 |
# File 'lib/lib/utils.rb', line 207 def nil? return '' if self == nil end |