Sha256: dc0a7660089c89e9018c63c882a6415db894848dc75767d61290bba4507b3b3f

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

Contents

module Skydrive
  # The file object
  class File < Skydrive::Object

    # The file size
    # @return [String]
    def size
      object["size"]      
    end

    # The number of comments associated with the file
    # @return [Integer]
    def comments_count
      object["comments_count"]
    end

    # A value that indicates whether comments are enabled for the file
    # @return [Boolean]
    def comments_enabled
      object["comments_enabled"]
    end

    # The URL to use to download the file from SkyDrive
    # @return [String]
    def source
      object["source"]
    end

    # The link that can be used to download the file
    # @return [String]
    def download_link
      url = client.get("/#{id}/content", :download => true, :suppress_redirects => true)["location"]
    end

    # Download the file
    def download
      uri = URI(download_link)
      response = HTTParty.get("http://#{uri.host}#{uri.path}?#{uri.query}")
      response.parsed_response
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
skydrive-0.1.4 lib/skydrive/file.rb
skydrive-0.1.0 lib/skydrive/file.rb
skydrive-0.0.2 lib/skydrive/file.rb