Class: Stomper::Frame
- Inherits:
-
Object
- Object
- Stomper::Frame
- Defined in:
- lib/stomper/frame.rb
Overview
A generic encapsulation of a frame as specified by the Stomp protocol.
Instance Attribute Summary collapse
-
#body ⇒ String
The body of this frame.
-
#command ⇒ String
The command name of this frame (CONNECTED, SEND, RECEIPT, etc.).
-
#headers ⇒ Stomper::Headers
readonly
The headers associated with this frame.
Instance Method Summary collapse
-
#[](name) ⇒ String
Gets the header value paired with the supplied name.
-
#[]=(name, val) ⇒ String
Sets the header value paired with the supplied name.
-
#content_type ⇒ String
A convenience method for getting the ‘content-type’ header without any parameters.
-
#initialize(command = nil, headers = {}, body = nil) ⇒ Frame
constructor
Creates a new frame.
Constructor Details
#initialize(command = nil, headers = {}, body = nil) ⇒ Frame
Creates a new frame. The frame will be initialized with the optional command
name, a headers collection initialized with the optional headers
hash, and an optional body.
20 21 22 23 24 |
# File 'lib/stomper/frame.rb', line 20 def initialize(command=nil, headers={}, body=nil) @command = command @headers = ::Stomper::Headers.new(headers) @body = body end |
Instance Attribute Details
#body ⇒ String
The body of this frame
11 12 13 |
# File 'lib/stomper/frame.rb', line 11 def body @body end |
#command ⇒ String
The command name of this frame (CONNECTED, SEND, RECEIPT, etc.)
7 8 9 |
# File 'lib/stomper/frame.rb', line 7 def command @command end |
#headers ⇒ Stomper::Headers (readonly)
The headers associated with this frame
15 16 17 |
# File 'lib/stomper/frame.rb', line 15 def headers @headers end |
Instance Method Details
#[](name) ⇒ String
Gets the header value paired with the supplied name. This is a convenient shortcut for ‘frame.headers`.
34 |
# File 'lib/stomper/frame.rb', line 34 def [](name); @headers[name]; end |
#[]=(name, val) ⇒ String
Sets the header value paired with the supplied name. This is a convenient shortcut for ‘frame.headers = val`.
46 |
# File 'lib/stomper/frame.rb', line 46 def []=(name, val); @headers[name] = val; end |
#content_type ⇒ String
A convenience method for getting the ‘content-type’ header without any parameters.
51 52 53 |
# File 'lib/stomper/frame.rb', line 51 def content_type @headers[:'content-type'] && @headers[:'content-type'].split(';').first || '' end |