Class: CresIP::Echo
- Inherits:
-
Object
- Object
- CresIP::Echo
- Defined in:
- lib/cresip/echo.rb
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(header, payload) ⇒ Echo
constructor
A new instance of Echo.
- #is_response? ⇒ Boolean
- #response ⇒ Object
- #to_binary_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(header, payload) ⇒ Echo
Returns a new instance of Echo.
10 11 12 13 |
# File 'lib/cresip/echo.rb', line 10 def initialize(header, payload) @header = header @payload = payload end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
15 16 17 |
# File 'lib/cresip/echo.rb', line 15 def header @header end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
15 16 17 |
# File 'lib/cresip/echo.rb', line 15 def payload @payload end |
Instance Method Details
#is_response? ⇒ Boolean
21 22 23 |
# File 'lib/cresip/echo.rb', line 21 def is_response? @header.type == :echo_response end |
#response ⇒ Object
25 26 27 28 29 30 |
# File 'lib/cresip/echo.rb', line 25 def response head = PacketHeader.new head.packet_type = PacketTypes[:echo_response] head.packet_size = @payload.length Echo.new(head, @payload) end |
#to_binary_s ⇒ Object
32 33 34 |
# File 'lib/cresip/echo.rb', line 32 def to_binary_s "#{@header.to_binary_s}#{@payload}" end |
#type ⇒ Object
17 18 19 |
# File 'lib/cresip/echo.rb', line 17 def type @header.type end |