Class: TgMq::Message
- Inherits:
-
Object
- Object
- TgMq::Message
- Includes:
- Enumerable
- Defined in:
- lib/tg_mq/message.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(seq, chunks, msg_id: Time.now.strftime('%L')) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(seq, chunks, msg_id: Time.now.strftime('%L')) ⇒ Message
Returns a new instance of Message.
11 12 13 14 15 |
# File 'lib/tg_mq/message.rb', line 11 def initialize(seq, chunks, msg_id: Time.now.strftime('%L')) @seq = seq @msg_id = msg_id @chunks = chunks end |
Class Method Details
.pack(seq, data, msg_id: Time.now.strftime('%L'), chunked: 4080) ⇒ Object
5 6 7 8 9 |
# File 'lib/tg_mq/message.rb', line 5 def self.pack(seq, data, msg_id: Time.now.strftime('%L'), chunked: 4080) (data + Frame::END_MSG).scan(/.{1,#{chunked}}/).each_with_index.map do |chunk, idx| Frame.new(seq, msg_id, idx, chunk) end end |