Class: Net::IMAP::PartialRange
- Inherits:
-
CommandData
- Object
- Data
- CommandData
- Net::IMAP::PartialRange
- Defined in:
- lib/net/imap/command_data.rb
Overview
:nodoc:
Constant Summary collapse
- POS_RANGE =
1..uint32_max
- NEG_RANGE =
-uint32_max..-1
- Positive =
->{ (_1 in Range) and POS_RANGE.cover?(_1) }
- Negative =
->{ (_1 in Range) and NEG_RANGE.cover?(_1) }
Instance Method Summary collapse
- #formatted ⇒ Object
-
#initialize(data:) ⇒ PartialRange
constructor
A new instance of PartialRange.
- #send_data(imap, tag) ⇒ Object
Methods inherited from CommandData
Constructor Details
#initialize(data:) ⇒ PartialRange
Returns a new instance of PartialRange.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/net/imap/command_data.rb', line 352 def initialize(data:) min, max = case data in Range data.minmax.map { Integer _1 } in ResponseParser::Patterns::PARTIAL_RANGE data.split(":").map { Integer _1 }.minmax else raise ArgumentError, "invalid partial range input: %p" % [data] end data = min..max unless data in Positive | Negative raise ArgumentError, "invalid partial-range: %p" % [data] end super rescue TypeError, RangeError raise ArgumentError, "expected range min/max to be Integers" end |
Instance Method Details
#formatted ⇒ Object
370 |
# File 'lib/net/imap/command_data.rb', line 370 def formatted = "%d:%d" % data.minmax |
#send_data(imap, tag) ⇒ Object
372 373 374 |
# File 'lib/net/imap/command_data.rb', line 372 def send_data(imap, tag) imap.__send__(:put_string, formatted) end |