Class: CloudApp::Drop
Overview
An ActiveResource-like interface through which to interract with CloudApp drops.
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) content_url
readonly
Returns the value of attribute content_url.
-
- (Object) created_at
readonly
Returns the value of attribute created_at.
-
- (Object) deleted_at
readonly
Returns the value of attribute deleted_at.
-
- (Object) href
readonly
Returns the value of attribute href.
-
- (Object) icon
readonly
Returns the value of attribute icon.
-
- (Object) item_type
readonly
Returns the value of attribute item_type.
-
- (Object) name
readonly
Returns the value of attribute name.
-
- (Object) private
readonly
Returns the value of attribute private.
-
- (Object) redirect_url
readonly
Returns the value of attribute redirect_url.
-
- (Object) remote_url
readonly
Returns the value of attribute remote_url.
-
- (Object) updated_at
readonly
Returns the value of attribute updated_at.
-
- (Object) url
readonly
Returns the value of attribute url.
-
- (Object) view_counter
readonly
Returns the value of attribute view_counter.
Class Method Summary (collapse)
-
+ (Array[CloudApp::Drop]) all(opts = {})
Page through your drops.
-
+ (CloudApp::Drop) create(kind, opts = {})
Create a new drop.
-
+ (CloudApp::Drop) delete(href)
Send a drop to the trash.
-
+ (CloudApp::Drop) find(id)
Get metadata about a cl.ly URL like name, type, or view count.
-
+ (CloudApp::Drop) recover(href)
Recover a drop from the trash.
-
+ (CloudApp::Drop) update(href, opts = {})
Modify a drop.
Instance Method Summary (collapse)
-
- (CloudApp::Drop) delete
Send the drop to the trash.
-
- (Drop) initialize(attributes = {})
constructor
Create a new CloudApp::Drop object.
-
- (CloudApp::Drop) recover
Recover the drop from the trash.
-
- (CloudApp::Drop) update(opts = {})
Modify the drop.
Methods inherited from Base
Constructor Details
- (Drop) initialize(attributes = {})
Create a new CloudApp::Drop object.
Only used internally.
162 163 164 |
# File 'lib/cloudapp/drop.rb', line 162 def initialize(attributes = {}) load(attributes) end |
Instance Attribute Details
- (Object) content_url (readonly)
Returns the value of attribute content_url
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def content_url @content_url end |
- (Object) created_at (readonly)
Returns the value of attribute created_at
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def created_at @created_at end |
- (Object) deleted_at (readonly)
Returns the value of attribute deleted_at
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def deleted_at @deleted_at end |
- (Object) href (readonly)
Returns the value of attribute href
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def href @href end |
- (Object) icon (readonly)
Returns the value of attribute icon
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def icon @icon end |
- (Object) item_type (readonly)
Returns the value of attribute item_type
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def item_type @item_type end |
- (Object) name (readonly)
Returns the value of attribute name
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def name @name end |
- (Object) private (readonly)
Returns the value of attribute private
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def private @private end |
- (Object) redirect_url (readonly)
Returns the value of attribute redirect_url
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def redirect_url @redirect_url end |
- (Object) remote_url (readonly)
Returns the value of attribute remote_url
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def remote_url @remote_url end |
- (Object) updated_at (readonly)
Returns the value of attribute updated_at
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def updated_at @updated_at end |
- (Object) url (readonly)
Returns the value of attribute url
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def url @url end |
- (Object) view_counter (readonly)
Returns the value of attribute view_counter
153 154 155 |
# File 'lib/cloudapp/drop.rb', line 153 def view_counter @view_counter end |
Class Method Details
+ (Array[CloudApp::Drop]) all(opts = {})
Page through your drops.
Requires authentication.
77 78 79 80 |
# File 'lib/cloudapp/drop.rb', line 77 def self.all(opts = {}) res = get "/items", {:query => (opts.empty? ? nil : opts), :digest_auth => @@auth} res.ok? ? res.collect{|i| Drop.new(i)} : res end |
+ (CloudApp::Drop) self.create(:bookmark, opts = {}) + (CloudApp::Drop) self.create(:bookmarks, bookmarks) + (CloudApp::Drop) self.create(:upload, opts = {})
Create a new drop. Multiple bookmarks can be created at once by passing an array of bookmark options parameters.
Requires authentication.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/cloudapp/drop.rb', line 99 def self.create(kind, opts = {}) case kind when :bookmark res = post "/items", {:body => {:item => opts}, :digest_auth => @@auth} when :bookmarks res = post "/items", {:body => {:items => opts}, :digest_auth => @@auth} when :upload r = get "/items/new", {:query => ({:item => {:private => opts[:private]}} if opts.has_key?(:private)), :digest_auth => @@auth} return r unless r.ok? res = post r['url'], Multipart.new(r['params'].merge!(:file => File.new(opts[:file]))).payload.merge!(:digest_auth => @@auth) else # TODO raise an error return false end res.ok? ? (res.is_a?(Array) ? res.collect{|i| Drop.new(i)} : Drop.new(res)) : res end |
+ (CloudApp::Drop) delete(href)
Send a drop to the trash.
Requires authentication.
136 137 138 139 140 |
# File 'lib/cloudapp/drop.rb', line 136 def self.delete(href) # Use delete on the Base class to avoid recursion res = Base.delete href, :digest_auth => @@auth res.ok? ? Drop.new(res) : res end |
+ (CloudApp::Drop) find(id)
Get metadata about a cl.ly URL like name, type, or view count.
Finds the drop by it's slug id, for example "2wr4".
62 63 64 65 |
# File 'lib/cloudapp/drop.rb', line 62 def self.find(id) res = get "http://cl.ly/#{id}" res.ok? ? Drop.new(res) : res end |
+ (CloudApp::Drop) recover(href)
Recover a drop from the trash.
Requires authentication.
148 149 150 151 |
# File 'lib/cloudapp/drop.rb', line 148 def self.recover(href) res = put href, {:body => {:deleted => true, :item => {:deleted_at => nil}}, :digest_auth => @@auth} res.ok? ? Drop.new(res) : res end |
+ (CloudApp::Drop) update(href, opts = {})
Modify a drop. Can currently modify it's name or security setting by passing parameters.
Requires authentication.
125 126 127 128 |
# File 'lib/cloudapp/drop.rb', line 125 def self.update(href, opts = {}) res = put href, {:body => {:item => opts}, :digest_auth => @@auth} res.ok? ? Drop.new(res) : res end |
Instance Method Details
- (CloudApp::Drop) delete
Send the drop to the trash.
179 180 181 |
# File 'lib/cloudapp/drop.rb', line 179 def delete self.class.delete self.href end |
- (CloudApp::Drop) recover
Recover the drop from the trash.
186 187 188 |
# File 'lib/cloudapp/drop.rb', line 186 def recover self.class.recover self.href end |
- (CloudApp::Drop) update(opts = {})
Modify the drop. Can currently modify it's name or security setting by passing parameters.
172 173 174 |
# File 'lib/cloudapp/drop.rb', line 172 def update(opts = {}) self.class.update self.href, opts end |