Class: Discorb::File
- Inherits:
 - 
      Object
      
        
- Object
 - Discorb::File
 
 
- Defined in:
 - lib/discorb/file.rb
 
Overview
Represents a file to send as an attachment.
Instance Attribute Summary collapse
- 
  
    
      #content_type -> String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The content type of the file.
 - 
  
    
      #filename -> String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The filename of the file.
 - 
  
    
      #io -> #read 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The IO of the file.
 
Instance Method Summary collapse
- 
  
    
      #initialize(io, filename = nil, content_type: nil) -> File 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of File.
 
Constructor Details
#initialize(io, filename = nil, content_type: nil) -> File
Returns a new instance of File.
      62 63 64 65 66 67  | 
    
      # File 'lib/discorb/file.rb', line 62 def initialize(io, filename = nil, content_type: nil) @io = io @filename = filename || (io.respond_to?(:path) ? io.path : io.object_id) @content_type = content_type || MIME::Types.type_for(@filename)[0].to_s @content_type = "application/octet-stream" if @content_type == "" end  | 
  
Instance Attribute Details
#content_type -> String
Returns The content type of the file. If not set, it is guessed from the filename.
      60 61 62  | 
    
      # File 'lib/discorb/file.rb', line 60 def content_type @content_type end  | 
  
#filename -> String
Returns The filename of the file. If not set, path or object_id of the IO is used.
      58 59 60  | 
    
      # File 'lib/discorb/file.rb', line 58 def filename @filename end  | 
  
#io -> #read
Returns The IO of the file.
      56 57 58  | 
    
      # File 'lib/discorb/file.rb', line 56 def io @io end  |