Converting to and from Ruby datatypes on Device