Module: Net::IMAP::StringFormatter
- Defined in:
- lib/net/imap/command_data.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
313 314 315 |
# File 'lib/net/imap/command_data.rb', line 313 def nstring(str) str.nil? ? nil : string(str) end |
.string(str) ⇒ Object
coerces using to_s
303 304 305 306 307 308 309 310 |
# File 'lib/net/imap/command_data.rb', line 303 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
298 299 300 |
# File 'lib/net/imap/command_data.rb', line 298 def valid_nstring?(str) str.nil? || valid_string?(str) end |
.valid_string?(str) ⇒ Boolean
Allows symbols in addition to strings
293 294 295 |
# File 'lib/net/imap/command_data.rb', line 293 def valid_string?(str) str.is_a?(Symbol) || str.respond_to?(:to_str) end |