Class: Cul::Handles::Hdl::UnsignedShort

Inherits:
Object
  • Object
show all
Defined in:
lib/cul/handles/hdl.rb

Class Method Summary collapse

Class Method Details

.asBytes(val) ⇒ Object



107
108
109
# File 'lib/cul/handles/hdl.rb', line 107

def UnsignedShort.asBytes(val)
  [(val&0xff00)>>8, val&0xff]
end

.fromBytes(data) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/cul/handles/hdl.rb', line 110

def UnsignedShort.fromBytes(data)
  result = data[-1]
  for i in ((data.length-1)..1)
    result |= (data[i] << (8*i))
  end
  return result
end