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.
- #help? ⇒ Boolean
-
#nil? ⇒ Boolean
Self test nil String class.
-
#num? ⇒ Boolean
Self test digits String class.
-
#numeric? ⇒ Boolean
Self test numeric String class.
Instance Method Details
#alnum? ⇒ Boolean
Self test alphanum String class.
342 343 344 |
# File 'lib/lib/utils.rb', line 342 def alnum? !!match(/^[[:alnum:]]+$/) end |
#alpha? ⇒ Boolean
Self test alpha String class.
349 350 351 |
# File 'lib/lib/utils.rb', line 349 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)
321 322 323 |
# File 'lib/lib/utils.rb', line 321 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)
310 311 312 |
# File 'lib/lib/utils.rb', line 310 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
294 295 296 297 298 299 300 301 |
# File 'lib/lib/utils.rb', line 294 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 |
#help? ⇒ Boolean
353 354 355 356 357 358 359 360 361 362 |
# File 'lib/lib/utils.rb', line 353 def help? if self.eql? '?' or self.eql? '-h' or self.eql? '--help' or self.eql? 'help' return true else return false end end |
#nil? ⇒ Boolean
Self test nil String class.
279 280 281 |
# File 'lib/lib/utils.rb', line 279 def nil? return '' if self == nil end |
#num? ⇒ Boolean
Self test digits String class.
335 336 337 |
# File 'lib/lib/utils.rb', line 335 def num? !!match(/^[[:digit:]]+$/) end |
#numeric? ⇒ Boolean
Self test numeric String class.
328 329 330 |
# File 'lib/lib/utils.rb', line 328 def numeric? Float(aux) != nil rescue false end |