Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string/count_string.rb,
lib/string/camelcase_string.rb,
lib/string/palindrome_string.rb
Instance Method Summary collapse
Instance Method Details
#camelcase ⇒ Object
4 5 6 7 |
# File 'lib/string/camelcase_string.rb', line 4 def camelcase str = split(/[^a-zA-Z]/) str.map { |el| el == str.first ? el : el.capitalize }.join end |
#count_chars ⇒ Object
4 5 6 |
# File 'lib/string/count_string.rb', line 4 def count_chars chars.group_by(&:itself).transform_values(&:count) end |
#palindrome? ⇒ Boolean
4 5 6 |
# File 'lib/string/palindrome_string.rb', line 4 def palindrome? downcase.eql?(downcase.reverse) end |