Class: CloudApp::Item
Overview
An ActiveResource-like interface through which to interract with the CloudApp API.
Instance Attribute Summary collapse
-
#content_url ⇒ Object
readonly
Returns the value of attribute content_url.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#deleted_at ⇒ Object
readonly
Returns the value of attribute deleted_at.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#item_type ⇒ Object
readonly
Returns the value of attribute item_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#private ⇒ Object
readonly
Returns the value of attribute private.
-
#redirect_url ⇒ Object
readonly
Returns the value of attribute redirect_url.
-
#remote_url ⇒ Object
readonly
Returns the value of attribute remote_url.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#view_counter ⇒ Object
readonly
Returns the value of attribute view_counter.
Class Method Summary collapse
-
.all(opts = {}) ⇒ Array[CloudApp::Item]
Page through your items.
-
.create(kind, opts = {}) ⇒ CloudApp::Item
Create a new cl.ly item.
-
.delete(href) ⇒ CloudApp::Item
Send an item to the trash.
-
.find(id) ⇒ CloudApp::Item
Get metadata about a cl.ly URL like name, type, or view count.
-
.update(href, opts = {}) ⇒ CloudApp::Item
Modify a cl.ly item.
Instance Method Summary collapse
-
#delete ⇒ CloudApp::Item
Send the item to the trash.
-
#initialize(attributes = {}) ⇒ Item
constructor
Create a new CloudApp::Item object.
-
#update(opts = {}) ⇒ CloudApp::Item
Modify the item.
Methods inherited from Base
Constructor Details
#initialize(attributes = {}) ⇒ Item
Create a new CloudApp::Item object.
Only used internally.
127 128 129 |
# File 'lib/cloudapp/item.rb', line 127 def initialize(attributes = {}) load(attributes) end |
Instance Attribute Details
#content_url ⇒ Object (readonly)
Returns the value of attribute content_url.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def content_url @content_url end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def created_at @created_at end |
#deleted_at ⇒ Object (readonly)
Returns the value of attribute deleted_at.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def deleted_at @deleted_at end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def href @href end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def icon @icon end |
#item_type ⇒ Object (readonly)
Returns the value of attribute item_type.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def item_type @item_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def name @name end |
#private ⇒ Object (readonly)
Returns the value of attribute private.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def private @private end |
#redirect_url ⇒ Object (readonly)
Returns the value of attribute redirect_url.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def redirect_url @redirect_url end |
#remote_url ⇒ Object (readonly)
Returns the value of attribute remote_url.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def remote_url @remote_url end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def updated_at @updated_at end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def url @url end |
#view_counter ⇒ Object (readonly)
Returns the value of attribute view_counter.
118 119 120 |
# File 'lib/cloudapp/item.rb', line 118 def view_counter @view_counter end |
Class Method Details
.all(opts = {}) ⇒ Array[CloudApp::Item]
Page through your items.
Requires authentication.
63 64 65 66 |
# File 'lib/cloudapp/item.rb', line 63 def self.all(opts = {}) res = get "/items?#{opts.to_params}", :digest_auth => @@auth res.ok? ? res.collect{|i| Item.new(i)} : res end |
.create(kind, opts = {}) ⇒ CloudApp::Item
Create a new cl.ly item.
Requires authentication.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/cloudapp/item.rb', line 78 def self.create(kind, opts = {}) case kind when :bookmark res = post "/items", {:body => {:item => opts}, :digest_auth => @@auth} when :upload res = get "/items/new", :digest_auth => @@auth return res unless res.ok? res = post res['url'], Multipart.new(res['params'].merge!(:file => File.new(opts[:file]))).payload.merge!(:digest_auth => @@auth) else # TODO raise an error return false end res.ok? ? Item.new(res) : res end |
.delete(href) ⇒ CloudApp::Item
Send an item to the trash.
Requires authentication.
113 114 115 116 |
# File 'lib/cloudapp/item.rb', line 113 def self.delete(href) res = Base.delete href, :digest_auth => @@auth res.ok? ? Item.new(res) : res end |
.find(id) ⇒ CloudApp::Item
Get metadata about a cl.ly URL like name, type, or view count.
Finds the item by it’s slug id, for example “2wr4”.
48 49 50 51 |
# File 'lib/cloudapp/item.rb', line 48 def self.find(id) res = get "http://cl.ly/#{id}" res.ok? ? Item.new(res) : res end |
.update(href, opts = {}) ⇒ CloudApp::Item
Modify a cl.ly item. Can currently modify it’s name or security setting by passing parameters.
Requires authentication.
102 103 104 105 |
# File 'lib/cloudapp/item.rb', line 102 def self.update(href, opts = {}) res = put href, {:body => {:item => opts}, :digest_auth => @@auth} res.ok? ? Item.new(res) : res end |
Instance Method Details
#delete ⇒ CloudApp::Item
Send the item to the trash.
Requires authentication.
148 149 150 |
# File 'lib/cloudapp/item.rb', line 148 def delete self.class.delete self.href end |
#update(opts = {}) ⇒ CloudApp::Item
Modify the item. Can currently modify it’s name or security setting by passing parameters.
Requires authentication.
139 140 141 |
# File 'lib/cloudapp/item.rb', line 139 def update(opts = {}) self.class.update self.href, opts end |