Class: MachO::MachOView

Inherits:
Object
  • Object
show all
Defined in:
lib/macho/view.rb

Overview

A representation of some unspecified Mach-O data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(macho_file, raw_data, endianness, offset) ⇒ MachOView

Creates a new MachOView.

Parameters:

  • macho_file (MachOFile)

    the file this view slice is from

  • raw_data (String)

    the raw Mach-O data

  • endianness (Symbol)

    the endianness of the data

  • offset (Integer)

    the offset of the relevant data



23
24
25
26
27
28
# File 'lib/macho/view.rb', line 23

def initialize(macho_file, raw_data, endianness, offset)
  @macho_file = macho_file
  @raw_data = raw_data
  @endianness = endianness
  @offset = offset
end

Instance Attribute Details

#endiannessSymbol (readonly)

Returns the endianness of the data (:big or :little).

Returns:

  • (Symbol)

    the endianness of the data (:big or :little)



13
14
15
# File 'lib/macho/view.rb', line 13

def endianness
  @endianness
end

#macho_fileMachOFile (readonly)

Returns that this view belongs to.

Returns:



7
8
9
# File 'lib/macho/view.rb', line 7

def macho_file
  @macho_file
end

#offsetInteger (readonly)

Returns the offset of the relevant data (in #raw_data).

Returns:

  • (Integer)

    the offset of the relevant data (in #raw_data)



16
17
18
# File 'lib/macho/view.rb', line 16

def offset
  @offset
end

#raw_dataString (readonly)

Returns the raw Mach-O data.

Returns:

  • (String)

    the raw Mach-O data



10
11
12
# File 'lib/macho/view.rb', line 10

def raw_data
  @raw_data
end

Instance Method Details

#inspectObject



38
39
40
# File 'lib/macho/view.rb', line 38

def inspect
  "#<#{self.class}:0x#{(object_id << 1).to_s(16)} @endianness=#{@endianness.inspect}, @offset=#{@offset.inspect}, length=#{@raw_data.length}>"
end

#to_hHash

Returns a hash representation of this MachO::MachOView.

Returns:



31
32
33
34
35
36
# File 'lib/macho/view.rb', line 31

def to_h
  {
    "endianness" => endianness,
    "offset" => offset,
  }
end