lib/wifly/calculations.rb in wifly-0.0.5 vs lib/wifly/calculations.rb in wifly-1.0.0

- old
+ new

@@ -3,12 +3,12 @@ ## # Parse the hexadecimal string returned from the show_io command # into an array of pins that are high # def parse_io(hex_str) - #"8d08" 36104 "1000110100001000" make it 16 bits - binary_string = hex_str .hex .to_s(2) .rjust(hex_str.size*4, '0') - binary_string.reverse.split("").each_with_index.map do |value, pin| + # use sprintf to pad with 0's to 16 bits + binary_string = "%016b" % hex_str.hex.to_i + binary_string.reverse.chars.each_with_index.map do |value, pin| pin if value == "1" end.compact end ## \ No newline at end of file