Module: Yescode::Strings
Constant Summary collapse
- SNAKE_CASE_REGEX =
/\B([A-Z])/
Instance Method Summary collapse
- #camel_case(str) ⇒ Object
- #class_name ⇒ Object
- #filename ⇒ Object
- #pascal_case(str) ⇒ Object
- #snake_case(str) ⇒ Object
Instance Method Details
#camel_case(str) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/yescode/strings.rb', line 11 def camel_case(str) result = pascal_case(str) result[0] = result[0].downcase result end |
#class_name ⇒ Object
22 23 24 |
# File 'lib/yescode/strings.rb', line 22 def class_name to_s.split("::").last end |
#filename ⇒ Object
26 27 28 |
# File 'lib/yescode/strings.rb', line 26 def filename snake_case(class_name) end |
#pascal_case(str) ⇒ Object
18 19 20 |
# File 'lib/yescode/strings.rb', line 18 def pascal_case(str) str.split("_").map(&:capitalize).join end |
#snake_case(str) ⇒ Object
7 8 9 |
# File 'lib/yescode/strings.rb', line 7 def snake_case(str) str.gsub(SNAKE_CASE_REGEX, '_\1').downcase end |