Class: Skydrive::Object

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

Overview

The base class for all objects

Direct Known Subclasses

Comment, File, Folder, Tag, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data) ⇒ Object

Returns a new instance of Object.



5
6
7
8
# File 'lib/skydrive/object.rb', line 5

def initialize client, data
  @client = client
  @object = data
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/skydrive/object.rb', line 4

def client
  @client
end

#objectObject (readonly)

Returns the value of attribute object.



4
5
6
# File 'lib/skydrive/object.rb', line 4

def object
  @object
end

Instance Method Details

#comment(options = {}) ⇒ Object

Make a comment about the object

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :message (String)

    The comment



108
109
110
# File 'lib/skydrive/object.rb', line 108

def comment options={}
  client.post("/#{id}/comments", options)
end

#commentsSkydrive::Collection

Comments associated with the object



101
102
103
# File 'lib/skydrive/object.rb', line 101

def comments
  client.get("/#{id}/comments")
end

#created_timeTime

The time at which the object was created.

Returns:

  • (Time)


48
49
50
# File 'lib/skydrive/object.rb', line 48

def created_time
  Time.parse(object["created_time"]) if object["created_time"]
end

#deleteObject

Delete the object from Skydrive



89
90
91
# File 'lib/skydrive/object.rb', line 89

def delete
  client.delete("/#{id}")
end

#descriptionString

Desciption of the object

Returns:

  • (String)


30
31
32
# File 'lib/skydrive/object.rb', line 30

def description
  object["description"]
end

#fromSkydrive::User

Info about the user who uploaded the file.

Returns:



18
19
20
# File 'lib/skydrive/object.rb', line 18

def from
  Skydrive::User.new(client,  object["from"]) if object["from"]
end

#idString

ID of the object

Returns:

  • (String)

    object id



12
13
14
# File 'lib/skydrive/object.rb', line 12

def id
  object["id"]
end

#is_embeddable?Boolean

A value that indicates whether this object can be embedded

Returns:

  • (Boolean)


95
96
97
# File 'lib/skydrive/object.rb', line 95

def is_embeddable?
  object["is_embeddable"]
end

A URL to view the item on SkyDrive

Returns:

  • (String)


42
43
44
# File 'lib/skydrive/object.rb', line 42

def link
  object["link"]
end

#nameString

Name of the object

Returns:

  • (String)


24
25
26
# File 'lib/skydrive/object.rb', line 24

def name
  object["name"]
end

#parent_idString

The ID of the parent object

Returns:

  • (String)


66
67
68
# File 'lib/skydrive/object.rb', line 66

def parent_id
  object["parent_id"]
end

#shared_withHash

The object that contains permission info.

Returns:

  • (Hash)


72
73
74
# File 'lib/skydrive/object.rb', line 72

def shared_with
  object["shared_with"]
end

#to_hashHash

Get the hash equivalent of the data

Returns:

  • (Hash)


84
85
86
# File 'lib/skydrive/object.rb', line 84

def to_hash
  object
end

#to_jsonString

Get json format object

Returns:

  • (String)


78
79
80
# File 'lib/skydrive/object.rb', line 78

def to_json
  object.to_json
end

#typeString

Type of object

Returns:

  • (String)


36
37
38
# File 'lib/skydrive/object.rb', line 36

def type
  object["type"]
end

#updated_timeTime

The time at which the object was updated.

Returns:

  • (Time)


54
55
56
# File 'lib/skydrive/object.rb', line 54

def updated_time
  Time.parse(object["updated_time"]) if object["updated_time"]
end

#upload_locationString

The URL to upload file content hosted in SkyDrive.

Returns:

  • (String)


60
61
62
# File 'lib/skydrive/object.rb', line 60

def upload_location
  object["upload_location"]
end