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.
276 277 278 279 280 281 |
# File 'lib/net/imap/command_data.rb', line 276 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
270 271 272 273 274 |
# File 'lib/net/imap/command_data.rb', line 270 def self.validate(...) data = new(...) data.validate data end |
Instance Method Details
#bytesize ⇒ Object
283 |
# File 'lib/net/imap/command_data.rb', line 283 def bytesize = data.bytesize |
#send_data(imap, tag) ⇒ Object
292 293 294 |
# File 'lib/net/imap/command_data.rb', line 292 def send_data(imap, tag) imap.__send__(:send_literal, data, tag, non_sync:) end |
#validate ⇒ Object
285 286 287 288 289 290 |
# File 'lib/net/imap/command_data.rb', line 285 def validate if data.include?("\0") raise DataFormatError, "NULL byte not allowed in #{self.class}. " \ "Use #{Literal8} or a null-safe encoding." end end |