From bfd6e1dde6cdb8b4cb4f7a89de6edc3a19e7c3cd Mon Sep 17 00:00:00 2001 From: Kuba Suder Date: Mon, 2 Feb 2026 16:27:20 +0200 Subject: [PATCH] tweaks to CAR section parsing behavior - when #sections is called, load all sections to the end - in #inspect output, show sections as [...] if not loaded --- lib/skyfall/car_archive.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/skyfall/car_archive.rb b/lib/skyfall/car_archive.rb index 7c56952..47c7491 100644 --- a/lib/skyfall/car_archive.rb +++ b/lib/skyfall/car_archive.rb @@ -53,6 +53,15 @@ module Skyfall nil end + def sections + if @buffer + read_section(@buffer) while !@buffer.eof? + @buffer = nil + end + + @sections + end + def self.convert_data(object) if object.is_a?(Hash) object.each do |k, v| @@ -87,6 +96,18 @@ module Skyfall { '$bytes' => Base64.encode64(data).chomp.gsub(/=+$/, '') } end + def inspect + vars = instance_variables.map { |v| + if v == :@sections && @buffer + "#{v}=[...]" + else + "#{v}=#{instance_variable_get(v).inspect}" + end + } + + "#<#{self.class}:0x#{object_id} #{vars.join(", ")}>" + end + private def read_header(buffer) -- 2.51.2