# Class BSV::Script::Chunk <a id="class-BSV-Script-Chunk"></a>

**Inherits:** `Object`

A single element of a parsed script — either an opcode or a data push.

Scripts are composed of a sequence of chunks. Each chunk is either a bare
opcode (e.g. `OP_DUP`) or a data push (opcode + data payload).

## Attributes
### `data` [R] <a id="attribute-i-data"></a> <a id="data-instance_method"></a>
- **@return** [String, nil] the pushed data bytes, or +nil+ for bare opcodes

### `opcode` [R] <a id="attribute-i-opcode"></a> <a id="opcode-instance_method"></a>
- **@return** [Integer] the opcode byte

## Public Instance Methods
### `==(other)` <a id="method-i--3D-3D"></a> <a id="==-instance_method"></a>
- **@param** `other` [Object] the object to compare
- **@return** [Boolean] +true+ if both chunks have equal opcode and data

### `data?()` <a id="method-i-data-3F"></a> <a id="data?-instance_method"></a>
Whether this chunk carries a data payload.
- **@return** [Boolean] +true+ if this is a data push chunk

### `initialize(opcode:, data: = nil)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
- **@param** `opcode` [Integer] the opcode byte value
- **@param** `data` [String, nil] data payload for push operations
- **@return** [Chunk] a new instance of Chunk

### `to_asm()` <a id="method-i-to_asm"></a> <a id="to_asm-instance_method"></a>
Render this chunk as human-readable ASM.

Data pushes are shown as hex strings; opcodes are shown by name. Opcodes with
no defined name are rendered as +OP_UNKNOWN<n>+ (e.g. `OP_UNKNOWN186`) so that
the output is unambiguous and round-trippable via `from_asm`.

The OP_RETURN opcode is special: it carries the raw tail bytes as its data
payload (absorbed during parsing). To preserve round-trip fidelity with
`from_asm`, the tail is re-parsed into individual push items and each is
rendered as a hex token after `OP_RETURN`.
- **@return** [String] ASM representation

### `to_binary()` <a id="method-i-to_binary"></a> <a id="to_binary-instance_method"></a>
Serialise this chunk back to raw script bytes.

Preserves the original push encoding (including non-minimal pushes) so that
round-tripping through parse/serialise does not alter the script bytes. This
is critical for sighash computation.
- **@return** [String] binary script bytes for this chunk
