Class: StompServer::StompFrame

Inherits:
Object
  • Object
show all
Defined in:
lib/stomp_server/stomp_frame.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command = nil, headers = nil, body = nil) ⇒ StompFrame

Returns a new instance of StompFrame.



5
6
7
8
9
# File 'lib/stomp_server/stomp_frame.rb', line 5

def initialize(command=nil, headers=nil, body=nil)
  @command = command
  @headers = headers || {}
  @body = body || ''
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/stomp_server/stomp_frame.rb', line 4

def body
  @body
end

#commandObject

Returns the value of attribute command.



4
5
6
# File 'lib/stomp_server/stomp_frame.rb', line 4

def command
  @command
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/stomp_server/stomp_frame.rb', line 4

def headers
  @headers
end

Instance Method Details

#destObject



22
23
24
25
# File 'lib/stomp_server/stomp_frame.rb', line 22

def dest
  #@dest || (@dest = @headers['destination'])
  @headers['destination']
end

#to_sObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/stomp_server/stomp_frame.rb', line 11

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