Class: AppInfo::DSYM::MachO

Inherits:
Object
  • Object
show all
Includes:
Helper::HumanFileSize
Defined in:
lib/app_info/dsym/macho.rb

Overview

Mach-O Struct

Constant Summary

Constants included from Helper::HumanFileSize

Helper::HumanFileSize::FILE_SIZE_UNITS

Instance Method Summary collapse

Methods included from Helper::HumanFileSize

#file_to_human_size, #number_to_human_size

Constructor Details

#initialize(file, size = 0) ⇒ MachO

Returns a new instance of MachO.



11
12
13
14
# File 'lib/app_info/dsym/macho.rb', line 11

def initialize(file, size = 0)
  @file = file
  @size = size
end

Instance Method Details

#cpu_nameString

Returns:

  • (String)


17
18
19
# File 'lib/app_info/dsym/macho.rb', line 17

def cpu_name
  @file.cpusubtype
end

#cpu_typeString

Returns:

  • (String)


22
23
24
# File 'lib/app_info/dsym/macho.rb', line 22

def cpu_type
  @file.cputype
end

#header::MachO::Headers

Returns:

  • (::MachO::Headers)


45
46
47
# File 'lib/app_info/dsym/macho.rb', line 45

def header
  @header ||= @file.header
end

#size(human_size: false) ⇒ String, Integer

Returns:

  • (String, Integer)


32
33
34
35
36
# File 'lib/app_info/dsym/macho.rb', line 32

def size(human_size: false)
  return number_to_human_size(@size) if human_size

  @size
end

#to_hHash{Symbol => String, Integer}

Returns:

  • (Hash{Symbol => String, Integer})


50
51
52
53
54
55
56
57
58
59
# File 'lib/app_info/dsym/macho.rb', line 50

def to_h
  {
    uuid: uuid,
    type: type,
    cpu_name: cpu_name,
    cpu_type: cpu_type,
    size: size,
    human_size: size(human_size: true)
  }
end

#typeString

Returns:

  • (String)


27
28
29
# File 'lib/app_info/dsym/macho.rb', line 27

def type
  @file.filetype
end

#uuidString Also known as: debug_id

Returns:

  • (String)


39
40
41
# File 'lib/app_info/dsym/macho.rb', line 39

def uuid
  @file[:LC_UUID][0].uuid_string
end