Module | Mail::Utilities::InstanceMethods |
In: |
lib/mail/utilities.rb
|
Capitalizes a string that is joined by hyphens correctly.
Example:
string = 'resent-from-field' capitalize_field( string ) #=> 'Resent-From-Field'
Takes an underscored word and turns it into a class name
Example:
constantize("hello") #=> "Hello" constantize("hello-there") #=> "HelloThere" constantize("hello-there-mate") #=> "HelloThereMate"
Swaps out all underscores (_) for hyphens (-) good for stringing from symbols a field name.
Example:
string = :resent_from_field dasherize ( string ) #=> 'resent_from_field'
Wraps supplied string in double quotes unless it is already wrapped.
Additionally will escape any double quotation marks in the string with a single backslash in front of the ’”’ character.
Escape parenthesies in a string
Example:
str = 'This is (a) string' escape_paren( str ) #=> 'This is \(a\) string'
Matches two objects with their to_s values case insensitively
Example:
obj2 = "This_is_An_object" obj1 = :this_IS_an_object match_to_s( obj1, obj2 ) #=> true
If the string supplied has ATOM unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified
If the string supplied has PHRASE unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified
If the string supplied has TOKEN unsafe characters in it, will return the string quoted in double quotes, otherwise returns the string unmodified
Swaps out all underscores (_) for hyphens (-) good for stringing from symbols a field name.
Example:
string = :resent_from_field underscoreize ( string ) #=> 'resent_from_field'
Unwraps a string from being wrapped in parenthesis
Example:
str = '(This is a string)' unparen( str ) #=> 'This is a string'