Class: Lignite::RbfObject
- Inherits:
-
Object
- Object
- Lignite::RbfObject
- 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
-
#body ⇒ ByteString
readonly
An already assembled body of the object.
Class Method Summary collapse
-
.block(owner:, triggers:, body:) ⇒ RbfObject
Make a Block object.
-
.subcall(body:, local_bytes:) ⇒ RbfObject
Make a Subcall object.
-
.vmthread(body:, local_bytes:) ⇒ RbfObject
Make a Vmthread object.
Instance Method Summary collapse
- #header(object_instruction_offset) ⇒ Object
-
#initialize(owner:, triggers:, local_bytes:, body:) ⇒ RbfObject
constructor
A new instance of RbfObject.
- #size ⇒ Object
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
#body ⇒ ByteString (readonly)
Returns 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.
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.
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.
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 |
#size ⇒ Object
31 32 33 |
# File 'lib/lignite/rbf_object.rb', line 31 def size HEADER_SIZE + body.bytesize end |