class String

Public Instance Methods

getbyte(index) click to toggle source
# File lib/rmodbus/ext.rb, line 4
def getbyte(index)
  self[index].to_i
end
getword(i) click to toggle source

Get word by index @param [Integer] i index first bytes of word @return unpacked word

# File lib/rmodbus/ext.rb, line 20
def getword(i)
  self[i,2].unpack('n')[0]
end
unpack_bits() click to toggle source
# File lib/rmodbus/ext.rb, line 9
def unpack_bits
  array_bit = []
  self.unpack('b*')[0].each_char do |c|
      array_bit << c.to_i
  end
  array_bit
end