Class: String
Instance Method Summary collapse
- #is_a_defined_class? ⇒ Boolean
-
#is_int? ⇒ Boolean
checks if string is a valid integer.
-
#to_class ⇒ Object
stole this from Afz902k who posted something similar at stackoverflow.com adds ability to check if a class with the name of a string exists.
Instance Method Details
#is_a_defined_class? ⇒ Boolean
71 72 73 74 75 |
# File 'lib/dust/helper.rb', line 71 def is_a_defined_class? true if self.to_class rescue NameError false end |
#is_int? ⇒ Boolean
checks if string is a valid integer
78 79 80 |
# File 'lib/dust/helper.rb', line 78 def is_int? true if Integer(self) rescue false end |
#to_class ⇒ Object
stole this from Afz902k who posted something similar at stackoverflow.com adds ability to check if a class with the name of a string exists
65 66 67 68 69 |
# File 'lib/dust/helper.rb', line 65 def to_class Kernel.const_get self.capitalize rescue NameError nil end |