Module: Net::IMAP::StringFormatter
- Defined in:
- lib/net/imap.rb
Constant Summary collapse
- LITERAL_REGEX =
/[\x80-\xff\r\n]/n
Class Method Summary collapse
-
.nstring(str) ⇒ Object
coerces non-nil using
to_s
. -
.string(str) ⇒ Object
coerces using
to_s
. -
.valid_nstring?(str) ⇒ Boolean
Allows nil, symbols, and strings.
-
.valid_string?(str) ⇒ Boolean
Allows symbols in addition to strings.
Class Method Details
.nstring(str) ⇒ Object
coerces non-nil using to_s
1804 1805 1806 |
# File 'lib/net/imap.rb', line 1804 def nstring(str) str.nil? ? nil : string(str) end |
.string(str) ⇒ Object
coerces using to_s
1794 1795 1796 1797 1798 1799 1800 1801 |
# File 'lib/net/imap.rb', line 1794 def string(str) str = str.to_s if str =~ LITERAL_REGEX Literal.new(str) else QuotedString.new(str) end end |
.valid_nstring?(str) ⇒ Boolean
Allows nil, symbols, and strings
1789 1790 1791 |
# File 'lib/net/imap.rb', line 1789 def valid_nstring?(str) str.nil? || valid_string?(str) end |
.valid_string?(str) ⇒ Boolean
Allows symbols in addition to strings
1784 1785 1786 |
# File 'lib/net/imap.rb', line 1784 def valid_string?(str) str.is_a?(Symbol) || str.respond_to?(:to_str) end |