def initialize(id, min: nil, sequence: 0)
@exclusive = false
case id
when '*'
@timestamp = (Time.now.to_f * 1000).to_i
@sequence = 0
if self <= min
@timestamp = min.timestamp
@sequence = min.sequence + 1
end
when '-'
@timestamp = @sequence = 0
when '+'
@timestamp = @sequence = Float::INFINITY
else
if id.is_a? String
(_, @timestamp, @sequence) = id.match(/^\(?(\d+)-?(\d+)?$/).to_a
@exclusive = true if id[0] == '('
if @timestamp.nil?
raise Redis::CommandError,
'ERR Invalid stream ID specified as stream command argument'
end
@timestamp = @timestamp.to_i
else
@timestamp = id
end
@sequence = @sequence.nil? ? sequence : @sequence.to_i
if self <= min
raise Redis::CommandError,
'ERR The ID specified in XADD is equal or smaller than ' \
'the target stream top item'
end
end
end