Class: ROS::Struct
- Inherits:
-
Object
- Object
- ROS::Struct
- Defined in:
- lib/ros/message.rb
Overview
used for serialization (for python like grammar) this is used by msg/srv converted *.rb files it can be removed, if there are more effective genmsg_ruby.
Instance Attribute Summary (collapse)
-
- (String) format
readonly
get the format string.
Class Method Summary (collapse)
-
+ (Integer) calc_size(format)
Calc the size.
Instance Method Summary (collapse)
-
- (Struct) initialize(format)
constructor
A new instance of Struct.
-
- (Object) pack(*args)
pack the data.
-
- (Array) unpack(arg)
unpack from string.
Constructor Details
- (Struct) initialize(format)
Returns a new instance of Struct
26 27 28 |
# File 'lib/ros/message.rb', line 26 def initialize(format) @format = format end |
Instance Attribute Details
- (String) format (readonly)
get the format string.
33 34 35 |
# File 'lib/ros/message.rb', line 33 def format @format end |
Class Method Details
+ (Integer) calc_size(format)
Calc the size
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ros/message.rb', line 39 def self.calc_size(format) array = [] start = 0 while start < format.length re = /(\w)(\d*)/ re =~ format[start..(format.length-1)] number = $2.to_i if number == 0 array.push(0) else for i in 1..number array.push(0) end end start += $&.length end array.pack(format).length end |
Instance Method Details
- (Object) pack(*args)
pack the data
60 61 62 |
# File 'lib/ros/message.rb', line 60 def pack(*args) args.pack(@format) end |
- (Array) unpack(arg)
unpack from string
67 68 69 |
# File 'lib/ros/message.rb', line 67 def unpack(arg) arg.unpack(@format) end |