Class: ErbLatex::StringIO

Inherits:
StringIO
  • Object
show all
Defined in:
lib/erb_latex/stringio.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = '') ⇒ StringIO

Returns a new instance of StringIO.



13
14
15
16
17
# File 'lib/erb_latex/stringio.rb', line 13

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

Instance Attribute Details

#filepathString

Returns complete virtual path for the data.

Returns:

  • (String)

    complete virtual path for the data



11
12
13
# File 'lib/erb_latex/stringio.rb', line 11

def filepath
  @filepath
end

Instance Method Details

#original_filenameObject

define original_filename for clients that depend on it, i.e. carrierwave



21
22
23
# File 'lib/erb_latex/stringio.rb', line 21

def original_filename
    File.basename(filepath)
end

#rename(name) ⇒ Object

reset filepath

Parameters:

  • name (String)

    new value for filepath

Returns:

  • self



28
29
30
31
# File 'lib/erb_latex/stringio.rb', line 28

def rename( name )
    @filepath = name
    self
end