Class: StompServer::StompId
- Inherits:
-
Object
- Object
- StompServer::StompId
- Defined in:
- lib/stomp_server_ng/stomp_id.rb
Instance Method Summary collapse
-
#[](id) ⇒ Object
Generate a ‘unique’ id based on:.
-
#initialize ⇒ StompId
constructor
Get current hostname.
Constructor Details
#initialize ⇒ StompId
Get current hostname
17 18 19 |
# File 'lib/stomp_server_ng/stomp_id.rb', line 17 def initialize @host = Socket.gethostname.to_s end |
Instance Method Details
#[](id) ⇒ Object
Generate a ‘unique’ id based on:
-
Host name
-
Current time
-
Called supplied id
27 28 29 30 |
# File 'lib/stomp_server_ng/stomp_id.rb', line 27 def [](id) msgid = sprintf("%.6f",Time.now.to_f).to_s.sub('.','-') msgid = @host + '-' + msgid + '-' + id.to_s end |