Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_augmentations/String/to_human.rb
Instance Method Summary collapse
-
#to_human ⇒ Object
take a CamelCase or under_scored string and convert it to a human readable string (useful for output).
Instance Method Details
#to_human ⇒ Object
take a CamelCase or under_scored string and convert it to a human readable string (useful for output).
3 4 5 6 7 |
# File 'lib/core_augmentations/String/to_human.rb', line 3 def to_human return self.split("_").map {|word| word[0] + word[1..-1]}.join(" ").capitalize if self.include?("_") return self.split(/(?=[A-Z])/).join(" ").capitalize end |