Class: Skydrive::File

Inherits:
Object
  • Object
show all
Defined in:
lib/skydrive/file.rb

Overview

The file object

Direct Known Subclasses

Audio, Notebook, Photo, Video

Instance Attribute Summary

Attributes inherited from Object

#client, #object

Instance Method Summary collapse

Methods inherited from Object

#comment, #comments, #created_time, #delete, #description, #from, #id, #initialize, #is_embeddable?, #link, #name, #parent_id, #shared_with, #to_hash, #to_json, #type, #updated_time, #upload_location

Constructor Details

This class inherits a constructor from Skydrive::Object

Instance Method Details

#comments_countInteger

The number of comments associated with the file

Returns:

  • (Integer)


13
14
15
# File 'lib/skydrive/file.rb', line 13

def comments_count
  object["comments_count"]
end

#comments_enabled?Boolean

A value that indicates whether comments are enabled for the file

Returns:

  • (Boolean)


19
20
21
# File 'lib/skydrive/file.rb', line 19

def comments_enabled?
  object["comments_enabled"]
end

#downloadObject

Download the file



36
37
38
39
40
# File 'lib/skydrive/file.rb', line 36

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

The link that can be used to download the file

Returns:

  • (String)


31
32
33
# File 'lib/skydrive/file.rb', line 31

def download_link
  url = client.get("/#{id}/content", :download => true, :suppress_redirects => true)["location"]
end

#sizeString

The file size

Returns:

  • (String)


7
8
9
# File 'lib/skydrive/file.rb', line 7

def size
  object["size"]      
end

#sourceString

The URL to use to download the file from SkyDrive

Returns:

  • (String)


25
26
27
# File 'lib/skydrive/file.rb', line 25

def source
  object["source"]
end