Class BSV::Script::Builder ¶
Inherits: Object
Fluent builder for constructing scripts incrementally.
Provides a chainable API for building scripts from opcodes and data pushes, as an alternative to the template constructors on {Script}.
@example Build a custom script
script = BSV::Script::Script.builder
.push_op(:OP_DUP)
.push_op(:OP_HASH160)
.push_data(pubkey_hash)
.push_op(:OP_EQUALVERIFY)
.push_op(:OP_CHECKSIG)
.build
Public Instance Methods¶
build() ¶
Finalise and return the constructed {Script}. - @return [Script] the built script
initialize() ¶
- @return [Builder] a new instance of Builder
push_data(data) ¶
Push raw binary data (automatically selects PUSHDATA encoding). - @param data [String] binary data to push - @return [self] for chaining
push_hex(hex) ¶
Push hex-encoded data. - @param hex [String] hex-encoded data to push - @return [self] for chaining
push_op(opcode) ¶
Push an opcode onto the script. - @param opcode [Symbol, Integer] opcode name (e.g. +:OP_DUP+) or byte value - @return [self] for chaining