Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_refinements/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).
6 7 8 9 10 |
# File 'lib/core_refinements/String/to_human.rb', line 6 def to_human return self.split("_").map {|word| word[0] + word[1..-1]}.join(" ") if self.include?("_") return self.split(/(?=[A-Z])/).join(" ").downcase end |