lib/rubyfit/helpers.rb
def str2bytes(str, byte_count)
    str
      .unpack("C#{byte_count - 1}") # Convert to n-1 bytes
      .map{|v| v || 0} + [0] # Convert nils to 0 and add null terminator
  end
# Converts an ASCII string into a byte array, truncating or right-filling
# with 0 to match byte_count
Converts an ASCII string into a byte array, truncating or right-filling
with 0 to match byte_count
Converts an ASCII string into a byte array truncating or right - filling with 0 to match byte_count
def str2bytes(str, byte_count)
    str
      .unpack("C#{byte_count - 1}") 
      .map{|v| v || 0} + [0] 
  end
def str2bytes ( str , byte_count ) str . unpack ( "C#{byte_count - 1}" ) . map { | v | v || 0 } + [ 0 ] end
Converts an ASCII string into a byte array, truncating or right-filling
with 0 to match byte_count
Converts an ASCII string into a byte array truncating or right - filling with 0 to match byte_count
# Convert to n-1 bytes # Convert nils to 0 and add null terminator
str
byte_count