Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo_followable/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#capitalized?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/mongo_followable/core_ext/string.rb', line 6

def capitalized?
  self[0].ord > 64 && self[0].ord < 91
end

#safe_capitalizeObject



10
11
12
13
14
15
16
17
18
# File 'lib/mongo_followable/core_ext/string.rb', line 10

def safe_capitalize
  if self.include? "_"
    self.split("_").map(&:capitalize).join
  elsif self[0].capitalized?
    self
  else
    self.capitalize
  end
end

#safe_capitalize_originalObject



3
# File 'lib/mongo_followable/core_ext/string.rb', line 3

alias safe_capitalize_original safe_capitalize