abstract class Bakelite::Item

Overview

Abstract representation of an embedded or stored virtual file.

Direct Known Subclasses

Defined in:

bakelite/item.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(path : String, volume_name : Symbol | String, size : Int64, compressed_size : Int64, mime_type : String, crc32 : UInt32, storage_mode : StorageMode) #

Instance Method Detail

def compressed_size : Int64 #

def content : String #

Alias for to_s for instant content inspection.


def crc32 : UInt32 #

def crc32_hex : String #

Hexadecimal formatted CRC32 checksum (e.g. "a1b2c3d4").


def etag : String #

HTTP-compliant ETag string based on CRC32 checksum and file size.


def extract(target_path : Path | String, overwrite : Bool = true) : Bool #

Extracts this virtual file to a target path on disk.


def mime_type : String #

abstract def open : IO #

Opens a readable stream for this asset.


def open(&block : IO -> T) : T forall T #

Yields an open stream to the block and automatically closes it upon completion.


def path : String #

def size : Int64 #

def storage_mode : StorageMode #

abstract def to_s(io : IO) : Nil #

Streams the content into the given output IO.


def to_s : String #

Returns the content as a UTF-8 String.


abstract def to_slice : Bytes #

Returns the full contents as a byte slice.


def volume_name : String #