Sha256: 85e1348d1dc4d6bc2611eefbca479d8fd1c2a6042b7ad9764116972bd5e85d89

Contents?: true

Size: 705 Bytes

Versions: 23

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

require_relative "visitor"

module Gem::SafeMarshal
  module Visitors
    class StreamPrinter < Visitor
      def initialize(io, indent: "")
        @io = io
        @indent = indent
        @level = 0
      end

      def visit(target)
        @io.write("#{@indent * @level}#{target.class}")
        target.instance_variables.each do |ivar|
          value = target.instance_variable_get(ivar)
          next if Elements::Element === value || Array === value
          @io.write(" #{ivar}=#{value.inspect}")
        end
        @io.write("\n")
        begin
          @level += 1
          super
        ensure
          @level -= 1
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rubygems-update-3.5.23 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.22 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.21 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.20 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.19 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.18 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.17 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.16 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.15 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.14 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.13 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.12 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.10 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.9 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.8 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.7 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.6 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.5 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.4 lib/rubygems/safe_marshal/visitors/stream_printer.rb
rubygems-update-3.5.3 lib/rubygems/safe_marshal/visitors/stream_printer.rb