Word wrap is now featured in the HumbleRPi-plugin-mtp gem by default

Previously If I had sent the following string to the printer:

Officejet 4500 4500W Remanufactured\nTesting this works, without a problem

It would have printed out as follows:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|                                  |
| Officejet 4500 4500W Remanufactu |
| red                              |
| Testing this works, without a pr |
| oblem                            |
|                                  |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Now using word wrap by default the same string would print as follows:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|                                  |
| Officejet 4500 4500W             |
| Remanufactured                   |
| Testing this works, without a    |
| problem                          |
|                                  |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Here's the code I used:

def wordwrap(s, cols=32)

  a = s.split(/ /)

  a2 = a.inject(['']) do |r,word|

    word.lines.each do |x|

      if (r[-1] + x).length <= cols then
        r[-1] << (r[-1].empty? ? x : ' ' + x)
      else
        r +=  &#9745;           end
      r[-1] = r[-1].chomp ; r += [''] if x[-1] == "\n"

    end
    r
  end

  a2.join("\n")

end

def printout(s)

  a2 = (" \n" + s + "\n ").lines.inject([]) do |r,x| 
    r + x.chomp.each_char.each_slice(32).map do |row|
      "| %s |" % (row.join + ' ' * 32).slice(0,32)
    end
  end
  "%s\n%s\n%s" % ['^' * 36, a2.join("\n"), '^' * 36]
end


s = "Officejet 4500 4500W Remanufactured\nTesting this works, without a problem"
puts printout(s)

s = "Officejet 4500 4500W Remanufactured\nTesting this works, without a problem"
puts printout(wordwrap(s))