Sha256: 08e96552e83276f2ba247da9b1c7b9c504d2c6cbdf7cc91c31e0bfaf9e2cf2a6

Contents?: true

Size: 871 Bytes

Versions: 4

Compression:

Stored size: 871 Bytes

Contents

module ErbLatex

    # An ErbLatex::StringIO extends Ruby's StringIO
    # with a path and file name
    # This allows it to be used in situations where a
    # File is expected
    class StringIO < ::StringIO

        # @attribute [rw] filepath
        #   @return [String] complete *virtual* path for the data
        attr_accessor :filepath

        def initialize( name='' )
            @filepath = name
            super('')
            self.set_encoding( Encoding.find("UTF-8") )
        end

        # define original_filename for clients that
        # depend on it, i.e. carrierwave
        def original_filename
            File.basename(filepath)
        end

        # reset filepath
        # @param name [String] new value for filepath
        # @return self
        def rename( name )
            @filepath = name
            self
        end
    end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
erb_latex-1.0.0 lib/erb_latex/stringio.rb
erb_latex-0.3.0 lib/erb_latex/stringio.rb
erb_latex-0.2.0 lib/erb_latex/stringio.rb
erb_latex-0.0.1 lib/erb_latex/stringio.rb