class Picasa::File

Constants

KnownExtensions

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/picasa/file.rb, line 15
def initialize(path)
  @path = path || raise(ArgumentError.new("path not specified"))
end

Public Instance Methods

binary() click to toggle source
# File lib/picasa/file.rb, line 27
def binary
  @binary ||= ::File.open(path, "rb").read
end
content_type() click to toggle source

Returns content type based on file extension You should use something like: ‘file -b –mime-type path/to/file.avi` to be sure what is the proper content type

# File lib/picasa/file.rb, line 34
def content_type
  @content_type ||= case extension
  when /^jpe?g$/i
    "image/jpeg"
  when /^gif$/i
    "image/gif"
  when /^png$/i
    "image/png"
  when /^bmp$/i
    "image/bmp"
  # Videos
  when /^3gp$/i
    "video/3gpp"
  when /^mp4$/i
    "video/mp4"
  when /^mpeg$/i
    "video/mpeg"
  when /^mov$/i
    "video/quicktime"
  when /^wmv$/i
    "video/x-ms-wmv"
  when /^asf$/i
    "video/x-ms-asf"
  when /^avi$/i
    "video/avi"
  else
    raise UnknownContentType.new("Content type cannot be guessed from file extension: #{extension}")
  end
end
extension() click to toggle source
# File lib/picasa/file.rb, line 23
def extension
  @extension ||= ::File.extname(path)[1..-1]
end
name() click to toggle source
# File lib/picasa/file.rb, line 19
def name
  @name ||= ::File.basename(path, ".*")
end