Class: Simrpc::Message::Body

Inherits:
Object
  • Object
show all
Defined in:
lib/simrpc/message.rb

Overview

body consists of a list of data fields

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Body

Returns a new instance of Body.



129
130
131
# File 'lib/simrpc/message.rb', line 129

def initialize(args = {})
  @fields = []
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



127
128
129
# File 'lib/simrpc/message.rb', line 127

def fields
  @fields
end

Class Method Details

.from_s(data) ⇒ Object



142
143
144
145
146
147
148
149
150
# File 'lib/simrpc/message.rb', line 142

def self.from_s(data)
  body = Body.new
  while(data != "")
     field, data = Formatter::parse_from_formatted(data)
     field = Field.from_s field
     body.fields.push field
  end
  return body
end

Instance Method Details

#to_sObject



133
134
135
136
137
138
139
140
# File 'lib/simrpc/message.rb', line 133

def to_s
   s = ''
   @fields.each { |field|
     fs = field.to_s
     s += Formatter::format_with_size(fs)
   }
   return s
end