Class: Simrpc::Message::Header
- Inherits:
-
Object
- Object
- Simrpc::Message::Header
- Defined in:
- lib/simrpc/message.rb
Overview
header contains various descriptive properies about a message
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Header
constructor
A new instance of Header.
- #to_s ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Header
Returns a new instance of Header.
106 107 108 109 110 |
# File 'lib/simrpc/message.rb', line 106 def initialize(args = {}) @id = args[:id].nil? ? "" : args[:id] @type = args[:type].nil? ? "" : args[:type] @target = args[:target].nil? ? "" : args[:target] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
104 105 106 |
# File 'lib/simrpc/message.rb', line 104 def id @id end |
#target ⇒ Object
Returns the value of attribute target.
104 105 106 |
# File 'lib/simrpc/message.rb', line 104 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
104 105 106 |
# File 'lib/simrpc/message.rb', line 104 def type @type end |
Class Method Details
.from_s(data) ⇒ Object
116 117 118 119 120 121 122 |
# File 'lib/simrpc/message.rb', line 116 def self.from_s(data) header = Header.new header.id, data = Formatter::parse_from_formatted_with_fixed_size(8, data) header.type, data = Formatter::parse_from_formatted(data) header.target, data = Formatter::parse_from_formatted(data) return header end |
Instance Method Details
#to_s ⇒ Object
112 113 114 |
# File 'lib/simrpc/message.rb', line 112 def to_s Formatter::format_with_fixed_size(8, @id) + Formatter::format_with_size(@type) + Formatter::format_with_size(@target) end |