Class: Net::IMAP::Literal
- Inherits:
-
Object
- Object
- Net::IMAP::Literal
- Defined in:
- lib/net/imap/command_data.rb
Overview
:nodoc:
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #bytesize ⇒ Object
-
#initialize(data:, non_sync: nil) ⇒ Literal
constructor
A new instance of Literal.
- #send_data(imap, tag) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(data:, non_sync: nil) ⇒ Literal
Returns a new instance of Literal.
346 347 348 349 350 351 |
# File 'lib/net/imap/command_data.rb', line 346 def initialize(data:, non_sync: nil) data = -String(data.to_str).b or raise DataFormatError, "#{self.class} expects string input" super validate end |
Class Method Details
.validate ⇒ Object
340 341 342 343 344 |
# File 'lib/net/imap/command_data.rb', line 340 def self.validate(...) data = new(...) data.validate data end |
Instance Method Details
#bytesize ⇒ Object
353 |
# File 'lib/net/imap/command_data.rb', line 353 def bytesize = data.bytesize |
#send_data(imap, tag) ⇒ Object
362 363 364 |
# File 'lib/net/imap/command_data.rb', line 362 def send_data(imap, tag) imap.__send__(:send_literal, data, tag, non_sync:) end |
#validate ⇒ Object
355 356 357 358 359 360 |
# File 'lib/net/imap/command_data.rb', line 355 def validate if data.include?("\0") raise DataFormatError, "NULL byte not allowed in #{self.class}. " \ "Use #{Literal8} or a null-safe encoding." end end |