class String

Public Instance Methods

is_a_defined_class?() click to toggle source
# File lib/dust/helper.rb, line 64
def is_a_defined_class?
  true if self.to_class
rescue NameError
  false
end
is_int?() click to toggle source

checks if string is a valid integer

# File lib/dust/helper.rb, line 71
def is_int?
  true if Integer(self) rescue false
end
to_class() click to toggle source

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

# File lib/dust/helper.rb, line 58
def to_class
  Kernel.const_get self.capitalize
rescue NameError
  nil
end