Class: StompFrame
- Inherits:
-
Object
- Object
- StompFrame
- Defined in:
- lib/stomp_frame.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#command ⇒ Object
Returns the value of attribute command.
-
#headers ⇒ Object
Returns the value of attribute headers.
Instance Method Summary collapse
- #dest ⇒ Object
-
#initialize(command = nil, headers = nil, body = nil) ⇒ StompFrame
constructor
A new instance of StompFrame.
- #to_s ⇒ Object
Constructor Details
#initialize(command = nil, headers = nil, body = nil) ⇒ StompFrame
Returns a new instance of StompFrame.
3 4 5 6 7 |
# File 'lib/stomp_frame.rb', line 3 def initialize(command=nil, headers=nil, body=nil) @command = command @headers = headers || {} @body = body || '' end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
2 3 4 |
# File 'lib/stomp_frame.rb', line 2 def body @body end |
#command ⇒ Object
Returns the value of attribute command.
2 3 4 |
# File 'lib/stomp_frame.rb', line 2 def command @command end |
#headers ⇒ Object
Returns the value of attribute headers.
2 3 4 |
# File 'lib/stomp_frame.rb', line 2 def headers @headers end |
Instance Method Details
#dest ⇒ Object
20 21 22 23 |
# File 'lib/stomp_frame.rb', line 20 def dest #@dest || (@dest = @headers['destination']) @headers['destination'] end |
#to_s ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/stomp_frame.rb', line 9 def to_s result = @command + "\n" @headers['content-length'] = @body.size.to_s if @body.include?(0) @headers.each_pair do |key, value| result << "#{key}:#{value}\n" end result << "\n" result << @body.to_s result << "\000\n" end |