Class: StompFrame

Inherits:
Object
  • Object
show all
Defined in:
lib/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.



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

#bodyObject

Returns the value of attribute body.



2
3
4
# File 'lib/stomp_frame.rb', line 2

def body
  @body
end

#commandObject

Returns the value of attribute command.



2
3
4
# File 'lib/stomp_frame.rb', line 2

def command
  @command
end

#headersObject

Returns the value of attribute headers.



2
3
4
# File 'lib/stomp_frame.rb', line 2

def headers
  @headers
end

Instance Method Details

#destObject



20
21
22
23
# File 'lib/stomp_frame.rb', line 20

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

#to_sObject



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