Class: Std_msgs::String
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Std_msgs::String
- Defined in:
- lib/std_msgs/String.rb
Constant Summary collapse
- @@struct_L =
::ROS::Struct.new("L")
- @@slot_types =
['string']
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
-
#_get_types ⇒ String
internal API method.
-
#deserialize(str) ⇒ Object
unpack serialized message in str into this message instance @param [String] str: byte array of serialized message.
- #has_header? ⇒ Boolean
-
#initialize(args = {}) ⇒ String
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ String
Constructor. You can set the default values using keyword operators.
35 36 37 38 39 40 41 42 |
# File 'lib/std_msgs/String.rb', line 35 def initialize(args={}) # message fields cannot be None, assign default values for those that are if args[:data] @data = args[:data] else @data = '' end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
25 26 27 |
# File 'lib/std_msgs/String.rb', line 25 def data @data end |
Class Method Details
.md5sum ⇒ Object
8 9 10 |
# File 'lib/std_msgs/String.rb', line 8 def self.md5sum "992ce8a1687cec8c8bd883ec73ca41d1" end |
.type ⇒ Object
12 13 14 |
# File 'lib/std_msgs/String.rb', line 12 def self.type "std_msgs/String" end |
Instance Method Details
#_get_types ⇒ String
internal API method
46 47 48 |
# File 'lib/std_msgs/String.rb', line 46 def _get_types @slot_types end |
#deserialize(str) ⇒ Object
unpack serialized message in str into this message instance
@param [String] str: byte array of serialized message
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/std_msgs/String.rb', line 65 def deserialize(str) begin end_point = 0 start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += length @data = str[start..(end_point-1)] return self rescue => exception raise "message DeserializationError: #{exception}" #most likely buffer underfill end end |
#has_header? ⇒ Boolean
16 17 18 |
# File 'lib/std_msgs/String.rb', line 16 def has_header? false end |
#message_definition ⇒ Object
20 21 22 23 24 |
# File 'lib/std_msgs/String.rb', line 20 def "string data " end |
#serialize(buff) ⇒ Object
serialize message into buffer
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/std_msgs/String.rb', line 52 def serialize(buff) begin _x = @data length = _x.length buff.write([length, _x].pack("La#{length}")) rescue => exception raise "some erro in serialize: #{exception}" end end |