Class: String
Instance Method Summary collapse
Instance Method Details
#date? ⇒ Boolean
62 63 64 65 66 67 68 |
# File 'lib/nested_hash_tricks/main.rb', line 62 def date? matches = (self =~ /\/\d+\//) || (self =~ /-\d+-/) matches2 = self =~ /^[ \d\-\/:]+$/ !!(matches && matches2 && Time.parse(self)) rescue return false end |
#num? ⇒ Boolean
59 60 61 |
# File 'lib/nested_hash_tricks/main.rb', line 59 def num? size > 0 && self =~ /^[\d\.]*$/ end |
#tmo ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/nested_hash_tricks/main.rb', line 72 def tmo if num? to_f.tmo elsif blank? nil else self end end |
#to_time ⇒ Object
69 70 71 |
# File 'lib/nested_hash_tricks/main.rb', line 69 def to_time Time.parse(self) end |