class GmailOauth::Attachment

Attributes

content[R]
file_name[R]
mime_type[R]

Public Class Methods

new(attachment) click to toggle source
# File lib/gmail_oauth/attachment.rb, line 5
def initialize(attachment)
  @file_name = attachment.filename
  @content = attachment.body.decoded
  @mime_type = get_mime_type
end

Public Instance Methods

file_extension() click to toggle source
# File lib/gmail_oauth/attachment.rb, line 11
def file_extension
  @file_name.split(".").last
end
get_mime_type() click to toggle source
# File lib/gmail_oauth/attachment.rb, line 15
def get_mime_type
  if mime_obj = MimeMagic.by_magic(content[0..10000])
    mime_obj.type
  end
end