Method: ErlangBitstream#str2int

Defined in:
lib/inspec/utils/erlang_parser.rb

#str2int(s, type) ⇒ Object



117
118
119
120
121
122
123
124
125
# File 'lib/inspec/utils/erlang_parser.rb', line 117

def str2int(s, type)
  case type
  when "utf8" then s.encode("utf-8").unpack("C*")
  when "utf16" then s.encode("utf-16").unpack("C*").drop(2)
  when "utf32" then s.encode("utf-32").unpack("C*").drop(4)
  when "integer", "float" then raise "Cannot handle bit string as type #{type}"
  else s.split("").map { |x| x.ord & 0xff }
  end
end