Sha256: e05a1d4547d492bf7e2f2f712f9bd9376ac51292cbcf1457534fa00d15c5c3f8

Contents?: true

Size: 807 Bytes

Versions: 31

Compression:

Stored size: 807 Bytes

Contents

require 'rabbit/source/base'

module Rabbit
  module Source
    class Memory
      include Base

      def self.initial_args_description
        N_("[FILENAME_OR_NOT]")
      end

      def initialize(encoding, logger, name=nil)
        super(encoding, logger)
        if name
          file_source = File.new(encoding, logger, name)
          @original_source = file_source.read
          set_base(file_source.base)
        else
          @original_source = ""
        end
        reset
      end

      def source=(new_source)
        @current_source = new_source
      end
      
      def _read
        @current_source
      end
      
      def need_read?
        super or @current_source != @source
      end

      def reset
        @current_source = @original_source.dup
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
rabbit-2.1.3 lib/rabbit/source/memory.rb
rabbit-2.1.2 lib/rabbit/source/memory.rb
rabbit-2.1.1 lib/rabbit/source/memory.rb
rabbit-2.1.0 lib/rabbit/source/memory.rb
rabbit-2.0.9 lib/rabbit/source/memory.rb
rabbit-2.0.8 lib/rabbit/source/memory.rb
rabbit-2.0.7 lib/rabbit/source/memory.rb
rabbit-2.0.6 lib/rabbit/source/memory.rb
rabbit-2.0.5 lib/rabbit/source/memory.rb
rabbit-2.0.4 lib/rabbit/source/memory.rb
rabbit-2.0.3 lib/rabbit/source/memory.rb
rabbit-2.0.2 lib/rabbit/source/memory.rb
rabbit-2.0.1 lib/rabbit/source/memory.rb
rabbit-2.0.0 lib/rabbit/source/memory.rb
rabbit-1.0.9 lib/rabbit/source/memory.rb
rabbit-1.0.8 lib/rabbit/source/memory.rb
rabbit-1.0.7 lib/rabbit/source/memory.rb
rabbit-1.0.6 lib/rabbit/source/memory.rb
rabbit-1.0.5 lib/rabbit/source/memory.rb
rabbit-1.0.4 lib/rabbit/source/memory.rb