Module | Mail::Utilities |
In: |
lib/mail/utilities.rb
|
Wraps a string in angle brackets and escapes any that are in the string itself
Example:
bracket( 'This is a string' ) #=> '<This is a string>'
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 and applies \-escaping as necessary, unless it is already wrapped.
Example:
string = 'This is a string' dquote(string) #=> '"This is a string"' string = 'This is "a string"' dquote(string #=> '"This is \"a string\"'
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
Wraps a string in parenthesis and escapes any that are in the string itself.
Example:
paren( 'This is a string' ) #=> '(This is a string)'
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
Unwraps a string from being wrapped in parenthesis
Example:
str = '<This is a string>' unbracket( str ) #=> 'This is a string'
Swaps out all hyphens (-) for underscores (_) good for stringing to 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'