class String
Public Instance Methods
to_classname()
click to toggle source
Returns a new string which supposed to represent a class name in accordance
with Ruby class naming convention
"my_class_name".to_classname # => "MyClassName"
# File lib/core/string.rb, line 9 def to_classname split(/[ _-]/).map(&:capitalize).join end
to_filename(prefix = nil)
click to toggle source
Returns a new string which supposed to represent a file name in accordance with folder/file naming convention.
"my new script".to_filename # => "my_new_script.rb" # using with prefix "my new script".to_filename :test # => "my_new_script_test.rb"
# File lib/core/string.rb, line 24 def to_filename(prefix = nil) split(/[ _-]/).map(&:downcase).join('_') + (prefix ? "_#{prefix}" : "") + ".rb" end