Class: ASE::File

Inherits:
File
  • Object
show all
Defined in:
lib/ase/file.rb

Constant Summary collapse

FORMATS =
{
  ulonglong: {
    length: 8,
    code: 'Q>'
  },
  longlong: {
    length: 8,
    code: 'q>'
  },
  double: {
    length: 8,
    code: 'G'
  },
  float: {
    length: 4,
    code: 'F'
  },
  uint: {
    length: 4,
    code: 'L>'
  },
  int: {
    length: 4,
    code: 'l>'
  },
  ushort: {
    length: 2,
    code: 'S>'
  },
  short: {
    length: 2,
    code: 's>'
  },
  ulong: {
    length: 4,
    code: 'L>'
  },
  long: {
    length: 4,
    code: 'l>'
  }
}

Instance Method Summary collapse

Instance Method Details

#read_stringObject



56
57
58
59
# File 'lib/ase/file.rb', line 56

def read_string
  length = read_ushort
  read(length * 2).encode('UTF-8', 'UTF-16BE').delete("\00")
end

#write_null_byteObject



67
68
69
# File 'lib/ase/file.rb', line 67

def write_null_byte
  write [0].pack('S>')
end

#write_string(string) ⇒ Object



61
62
63
64
65
# File 'lib/ase/file.rb', line 61

def write_string(string)
  write_ushort(string.length + 1)
  write string.encode('UTF-16BE')
  write_null_byte
end