Class: XiamiRadio::Notice
- Inherits:
-
Object
- Object
- XiamiRadio::Notice
- Defined in:
- lib/xiami_radio/notice.rb
Class Method Summary collapse
Class Method Details
.push(msg, expired = 3) ⇒ Object
5 6 7 |
# File 'lib/xiami_radio/notice.rb', line 5 def push(msg, expired = 3) queue << { content: msg, expired_at: Time.now.to_i + expired } end |
.queue ⇒ Object
14 15 16 |
# File 'lib/xiami_radio/notice.rb', line 14 def queue @queue ||= [] end |
.shift ⇒ Object
9 10 11 12 |
# File 'lib/xiami_radio/notice.rb', line 9 def shift queue.shift until queue.empty? || queue.first[:expired_at] > Time.now.to_i queue.first&.fetch(:content, nil) end |