Class: Simrpc::Message::Field
- Inherits:
-
Object
- Object
- Simrpc::Message::Field
- Defined in:
- lib/simrpc/message.rb
Overview
a single field trasnmitted via a message, containing a key / value pair
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Field
constructor
A new instance of Field.
- #to_s ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Field
Returns a new instance of Field.
84 85 86 87 |
# File 'lib/simrpc/message.rb', line 84 def initialize(args = {}) @name = args[:name].nil? ? "" : args[:name] @value = args[:value].nil? ? "" : args[:value] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
82 83 84 |
# File 'lib/simrpc/message.rb', line 82 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
82 83 84 |
# File 'lib/simrpc/message.rb', line 82 def value @value end |
Class Method Details
.from_s(data) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/simrpc/message.rb', line 93 def self.from_s(data) field = Field.new field.name, data = Formatter::parse_from_formatted(data) field.value, data = Formatter::parse_from_formatted(data) return field end |
Instance Method Details
#to_s ⇒ Object
89 90 91 |
# File 'lib/simrpc/message.rb', line 89 def to_s Formatter::format_with_size(@name) + Formatter::format_with_size(@value) end |