Module: WebfleetConnect::Helpers::CaseHelper
- Included in:
- Params::Param, Actions
- Defined in:
- lib/webfleet_connect/helpers/case_helper.rb
Instance Method Summary collapse
- #pascal_to_cammel(str) ⇒ Object
- #pascal_to_snake(str) ⇒ Object
- #snake_to_cammel(str) ⇒ Object
- #snake_to_pascal(str) ⇒ Object
Instance Method Details
#pascal_to_cammel(str) ⇒ Object
6 7 8 |
# File 'lib/webfleet_connect/helpers/case_helper.rb', line 6 def pascal_to_cammel(str) str[0].downcase + str[1..] end |
#pascal_to_snake(str) ⇒ Object
2 3 4 |
# File 'lib/webfleet_connect/helpers/case_helper.rb', line 2 def pascal_to_snake(str) str.gsub(/([a-z])([A-Z])/, '\1_\2').downcase end |
#snake_to_cammel(str) ⇒ Object
14 15 16 17 |
# File 'lib/webfleet_connect/helpers/case_helper.rb', line 14 def snake_to_cammel(str) pascal = snake_to_pascal(str) pascal_to_cammel(pascal) end |
#snake_to_pascal(str) ⇒ Object
10 11 12 |
# File 'lib/webfleet_connect/helpers/case_helper.rb', line 10 def snake_to_pascal(str) str.split('_').map(&:capitalize).join('') end |