Module: DroneCollectd::CollectdGenerator
- Defined in:
- lib/drone_collectd/parser.rb
Class Method Summary collapse
-
.number(type, num) ⇒ Object
Encode an integer.
-
.string(type, str) ⇒ Object
Encode a string (type 0, null terminated string).
Class Method Details
.number(type, num) ⇒ Object
Encode an integer
81 82 83 |
# File 'lib/drone_collectd/parser.rb', line 81 def self.number(type, num) [type, 12].pack("nn") + [num >> 32, num & 0xffffffff].pack("NN") end |
.string(type, str) ⇒ Object
Encode a string (type 0, null terminated string)
74 75 76 77 78 |
# File 'lib/drone_collectd/parser.rb', line 74 def self.string(type, str) str += "\000" str_size = str.respond_to?(:bytesize) ? str.bytesize : str.size [type, 4 + str_size].pack("nn") + str end |