Class: Lignite::RbfObject

Inherits:
Object
  • Object
show all
Includes:
Bytes
Defined in:
lib/lignite/rbf_object.rb

Overview

Part of an assembled RBF file

Constant Summary collapse

HEADER_SIZE =
12

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Bytes

#bin_to_hex, #f32, #hex_to_bin, #u16, #u32, #u8, #unpack_f32, #unpack_u16, #unpack_u32, #unpack_u8

Constructor Details

#initialize(owner:, triggers:, local_bytes:, body:) ⇒ RbfObject

Returns a new instance of RbfObject.



23
24
25
26
27
28
# File 'lib/lignite/rbf_object.rb', line 23

def initialize(owner:, triggers:, local_bytes:, body:)
  @owner = owner
  @triggers = triggers
  @local_bytes = local_bytes
  @body = body
end

Instance Attribute Details

#bodyByteString (readonly)

Returns an already assembled body of the object.

Returns:

  • (ByteString)

    an already assembled body of the object



21
22
23
# File 'lib/lignite/rbf_object.rb', line 21

def body
  @body
end

Class Method Details

.block(owner:, triggers:, body:) ⇒ RbfObject

Returns make a Block object.

Returns:



16
17
18
# File 'lib/lignite/rbf_object.rb', line 16

def self.block(owner:, triggers:, body:)
  new(owner: owner, triggers: triggers, local_bytes: 0, body: body)
end

.subcall(body:, local_bytes:) ⇒ RbfObject

Returns make a Subcall object.

Returns:



11
12
13
# File 'lib/lignite/rbf_object.rb', line 11

def self.subcall(body:, local_bytes:)
  new(owner: 0, triggers: 1, local_bytes: local_bytes, body: body)
end

.vmthread(body:, local_bytes:) ⇒ RbfObject

Returns make a Vmthread object.

Returns:



6
7
8
# File 'lib/lignite/rbf_object.rb', line 6

def self.vmthread(body:, local_bytes:)
  new(owner: 0, triggers: 0, local_bytes: local_bytes, body: body)
end

Instance Method Details

#header(object_instruction_offset) ⇒ Object



35
36
37
38
# File 'lib/lignite/rbf_object.rb', line 35

def header(object_instruction_offset)
  u32(object_instruction_offset) +
    u16(@owner) + u16(@triggers) + u32(@local_bytes)
end

#sizeObject



31
32
33
# File 'lib/lignite/rbf_object.rb', line 31

def size
  HEADER_SIZE + body.bytesize
end