Sha256: eba7ecbb8ca6bad385c1eb912d77dd03e0d2f385f6874d0bfdb752ccfac4e5d5

Contents?: true

Size: 996 Bytes

Versions: 4

Compression:

Stored size: 996 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

4 entries across 4 versions & 1 rubygems

Version Path
skydrive-1.2.0 lib/skydrive/file.rb
skydrive-1.1.0 lib/skydrive/file.rb
skydrive-1.0.0 lib/skydrive/file.rb
skydrive-0.1.5 lib/skydrive/file.rb