Sha256: ba463bb64852f24cc8904239618f70451bdc24fadf87568e9bd729aee1d70582
Contents?: true
Size: 524 Bytes
Versions: 5
Compression:
Stored size: 524 Bytes
Contents
require 'mime/types' class Happi::File attr_accessor :file_name attr_accessor :mime_type def initialize(file) if file.is_a?(String) @mime_type = MIME::Types.type_for(file).first.content_type @file_name = file else @mime_type = file.content_type @file_name = file.path end end def exists? File.exists?(file_name) end def multipart Faraday::UploadIO.new(file_name, mime_type) if exists? end def encode_file Base64.encode64(File.read(file_name)) end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
happi-0.2.0 | lib/happi/file.rb |
happi-0.1.0 | lib/happi/file.rb |
happi-0.0.12 | lib/happi/file.rb |
happi-0.0.11 | lib/happi/file.rb |
happi-0.0.10 | lib/happi/file.rb |