module Net::IMAP::Literal::Literal8::PartialRange::StringFormatter
Constants
- LITERAL_REGEX
Public Instance Methods
Source
# File lib/net/imap/command_data.rb, line 251 def literal_or_literal8(input, name: "argument") return input if input in Literal | Literal8 data = String.try_convert(input) \ or raise TypeError, "expected #{name} to be String, got #{input.class}" type = data.include?("\0") ? Literal8 : Literal type.new(data:) end
Source
# File lib/net/imap/command_data.rb, line 280 def nstring(str) str.nil? ? nil : string(str) end
coerces non-nil using to_s
Source
# File lib/net/imap/command_data.rb, line 270 def string(str) str = str.to_s if str =~ LITERAL_REGEX Literal.new(str) else QuotedString.new(str) end end
coerces using to_s
Source
# File lib/net/imap/command_data.rb, line 265 def valid_nstring?(str) str.nil? || valid_string?(str) end
Allows nil, symbols, and strings
Source
# File lib/net/imap/command_data.rb, line 260 def valid_string?(str) str.is_a?(Symbol) || str.respond_to?(:to_str) end
Allows symbols in addition to strings