Class: Mack::Testing::FileWrapper
Overview
:nodoc:
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#mime ⇒ Object
readonly
Returns the value of attribute mime.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#initialize(path) ⇒ FileWrapper
constructor
A new instance of FileWrapper.
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
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/mack/testing/file.rb', line 8 def content @content end |
#file_name ⇒ Object (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 |
#mime ⇒ Object (readonly)
Returns the value of attribute mime.
10 11 12 |
# File 'lib/mack/testing/file.rb', line 10 def mime @mime end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/mack/testing/file.rb', line 6 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/mack/testing/file.rb', line 9 def size @size end |