Sha256: 872e1f0ae6fdbf0f2b68e2fa869bc6e2a96f881429540e32cb0e171de11d9489

Contents?: true

Size: 727 Bytes

Versions: 5

Compression:

Stored size: 727 Bytes

Contents

module Picasa
  class File
    attr_reader :path

    def initialize(path)
      @path = path || raise(ArgumentError.new("path not specified"))
    end

    def name
      @name ||= ::File.basename(path, ".*")
    end

    def extension
      @extension ||= ::File.extname(path)[1..-1]
    end

    def binary
      @binary ||= ::File.open(path, "rb").read
    end

    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"
      else
        raise StandarError.new("Content type cannot be guessed from file extension: #{extension}")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
picasa-0.5.4 lib/picasa/file.rb
picasa-0.5.3 lib/picasa/file.rb
picasa-0.5.2 lib/picasa/file.rb
picasa-0.5.1 lib/picasa/file.rb
picasa-0.5.0 lib/picasa/file.rb