Class: Roart::Attachment
- Inherits:
-
Struct
- Object
- Struct
- Roart::Attachment
- Defined in:
- lib/roart/attachment.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file
13 14 15 |
# File 'lib/roart/attachment.rb', line 13 def file @file end |
#name ⇒ Object
Returns the value of attribute name
13 14 15 |
# File 'lib/roart/attachment.rb', line 13 def name @name end |
Class Method Details
.detect(*args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/roart/attachment.rb', line 23 def self.detect(*args) AttachmentCollection.new Array(args.compact).flatten.map { |file| if file.is_a?(File) Attachment.new(File.basename(file.path), file) elsif file.is_a?(String) Attachment.new(File.basename(file), File.open(file, 'rb')) elsif file.respond_to?(:open, :original_filename) Attachment.new(file.original_filename, file.open) end }.compact end |
Instance Method Details
#path ⇒ Object
15 16 17 |
# File 'lib/roart/attachment.rb', line 15 def path name end |
#read ⇒ Object
19 20 21 |
# File 'lib/roart/attachment.rb', line 19 def read file.read end |