Class: Mack::Testing::FileWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/mack/testing/file.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileWrapper

Returns a new instance of FileWrapper.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mack/testing/file.rb', line 12

def initialize(path)
  @path = path
  @file_name = File.basename(path)
  extension = File.extname(path)
  extension = extension.gsub!(".", "")
  if extension and !extension.empty?
    @mime     = Mack::Utils::MimeTypes.instance.get(extension) if extension
  else
    @mime     = "application/octet-stream"
  end
  raw_content = File.read(path)
  @content = Base64.encode64(raw_content).strip
  @size    = @content.size
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/mack/testing/file.rb', line 8

def content
  @content
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



7
8
9
# File 'lib/mack/testing/file.rb', line 7

def file_name
  @file_name
end

#mimeObject (readonly)

Returns the value of attribute mime.



10
11
12
# File 'lib/mack/testing/file.rb', line 10

def mime
  @mime
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/mack/testing/file.rb', line 6

def path
  @path
end

#sizeObject (readonly)

Returns the value of attribute size.



9
10
11
# File 'lib/mack/testing/file.rb', line 9

def size
  @size
end