Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/dust/helper.rb

Instance Method Summary collapse

Instance Method Details

#is_a_defined_class?Boolean

Returns:

  • (Boolean)


64
65
66
67
68
# File 'lib/dust/helper.rb', line 64

def is_a_defined_class?
  true if self.to_class
rescue NameError
  false
end

#is_int?Boolean

checks if string is a valid integer

Returns:

  • (Boolean)


71
72
73
# File 'lib/dust/helper.rb', line 71

def is_int?
  true if Integer(self) rescue false
end

#to_classObject

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



58
59
60
61
62
# File 'lib/dust/helper.rb', line 58

def to_class
  Kernel.const_get self.capitalize
rescue NameError
  nil
end