]>
git.r.bdr.sh - rbdr/lyricli.rb/blob - lib/lyricli/util.rb
2 # This module contains several utility functions.
5 # Transforms a string from snake_case to UpperCamelCase
7 # @param [String] str the string that will be Camelized
8 # @return [String] the Camelized string.
10 str
.split('_').map
{|w
| w
.capitalize
}.join
13 # Takes a class name in snake_case and attempts to find the corresponding
14 # class from the sources.
16 # @param [String] class_name the snake_case name of the class to search for.
17 # @return [Class,nil] the found class or nil
18 def parse_class(class_name
)
20 path
= "Sources::#{class_name}"
27 # Simply escapes a param and substitutes spaces and escaped plus signs for
30 # @param [String] p the parameter to be sanitized
31 # @return [String] the sanitized parameter
33 CGI
.escape(p
.gsub(/ /, "+")).gsub("%2B
", "+
")