Class: WarCorrespondent::Uplink
- Inherits:
-
Object
- Object
- WarCorrespondent::Uplink
- Defined in:
- lib/warcorrespondent/uplink.rb
Instance Attribute Summary collapse
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #add(message) ⇒ Object
-
#initialize ⇒ Uplink
constructor
A new instance of Uplink.
- #run ⇒ Object
- #sync ⇒ Object
Constructor Details
#initialize ⇒ Uplink
Returns a new instance of Uplink.
8 9 10 |
# File 'lib/warcorrespondent/uplink.rb', line 8 def initialize @@messages = [] end |
Instance Attribute Details
#secret ⇒ Object
Returns the value of attribute secret.
6 7 8 |
# File 'lib/warcorrespondent/uplink.rb', line 6 def secret @secret end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/warcorrespondent/uplink.rb', line 5 def url @url end |
Instance Method Details
#add(message) ⇒ Object
12 13 14 |
# File 'lib/warcorrespondent/uplink.rb', line 12 def add() @@messages << end |
#run ⇒ Object
31 32 33 34 35 36 |
# File 'lib/warcorrespondent/uplink.rb', line 31 def run loop do sync sleep 1 end end |
#sync ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/warcorrespondent/uplink.rb', line 16 def sync return if @@messages.size == 0 buffer = [] 10.times do buffer << @@messages.shift if @@messages.size > 0 end buffer.each do || begin post(encode()) rescue add() end end end |