Class: String

Inherits:
Object
  • Object
show all
Defined in:
server/lib/game_machine/ruby_extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)

6
7
8
# File 'server/lib/game_machine/ruby_extensions/string.rb', line 6

def blank?
  self !~ /\S/
end

#constantizeObject


2
3
4
# File 'server/lib/game_machine/ruby_extensions/string.rb', line 2

def constantize
  self.split("::").inject(Module) {|acc, val| acc.const_get(val)}
end

#underscoreObject


10
11
12
13
14
15
16
# File 'server/lib/game_machine/ruby_extensions/string.rb', line 10

def underscore
  self.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").
  downcase
end