Sha256: 84e369b8c113e69756a7f371382c9e72da2c0ab9ba092d2178b846c4cf93841b

Contents?: true

Size: 721 Bytes

Versions: 5

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

module RubySmart
  module SimpleLogger
    module Devices
      class MemoryDevice
        attr_reader :logs
        attr_reader :status

        def initialize
          @logs   = []
          @status = true
        end

        # adds data to the logs
        # @param [Object] data
        def write(data)
          return false unless status

          @logs << data
        end

        alias_method :<<, :write

        # disables writing
        def close
          @status = false
        end

        # enables writing
        def reopen
          @status = true
        end

        # clears all logs
        def clear!
          @logs = []
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby_smart-simple_logger-1.5.3 lib/ruby_smart/simple_logger/devices/memory_device.rb
ruby_smart-simple_logger-1.5.2 lib/ruby_smart/simple_logger/devices/memory_device.rb
ruby_smart-simple_logger-1.5.1 lib/ruby_smart/simple_logger/devices/memory_device.rb
ruby_smart-simple_logger-1.5.0 lib/ruby_smart/simple_logger/devices/memory_device.rb
ruby_smart-simple_logger-1.4.0 lib/ruby_smart/simple_logger/devices/memory_device.rb