Class: Roscpp::Logger
- Inherits:
-
ROS::Message
- Object
- ROS::Message
- Roscpp::Logger
- Defined in:
- lib/roscpp/Logger.rb
Constant Summary collapse
- @@struct_L =
::ROS::Struct.new("L")
- @@slot_types =
['string','string']
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#name ⇒ Object
Returns the value of attribute name.
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 = {}) ⇒ Logger
constructor
Constructor.
- #message_definition ⇒ Object
-
#serialize(buff) ⇒ Object
serialize message into buffer.
Constructor Details
#initialize(args = {}) ⇒ Logger
Constructor. You can set the default values using keyword operators.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/roscpp/Logger.rb', line 37 def initialize(args={}) # message fields cannot be None, assign default values for those that are if args[:name] @name = args[:name] else @name = '' end if args[:level] @level = args[:level] else @level = '' end end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
26 27 28 |
# File 'lib/roscpp/Logger.rb', line 26 def level @level end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/roscpp/Logger.rb', line 26 def name @name end |
Class Method Details
.md5sum ⇒ Object
8 9 10 |
# File 'lib/roscpp/Logger.rb', line 8 def self.md5sum "a6069a2ff40db7bd32143dd66e1f408e" end |
.type ⇒ Object
12 13 14 |
# File 'lib/roscpp/Logger.rb', line 12 def self.type "roscpp/Logger" end |
Instance Method Details
#_get_types ⇒ String
internal API method
53 54 55 |
# File 'lib/roscpp/Logger.rb', line 53 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
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/roscpp/Logger.rb', line 75 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 @name = str[start..(end_point-1)] start = end_point end_point += 4 (length,) = @@struct_L.unpack(str[start..(end_point-1)]) start = end_point end_point += length @level = 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/roscpp/Logger.rb', line 16 def has_header? false end |
#message_definition ⇒ Object
20 21 22 23 24 25 |
# File 'lib/roscpp/Logger.rb', line 20 def "string name string level " end |
#serialize(buff) ⇒ Object
serialize message into buffer
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/roscpp/Logger.rb', line 59 def serialize(buff) begin _x = @name length = _x.length buff.write([length, _x].pack("La#{length}")) _x = @level length = _x.length buff.write([length, _x].pack("La#{length}")) rescue => exception raise "some erro in serialize: #{exception}" end end |