class CrateAPI::Item
Item
class which is used to manipulate and represent a file blob which is inside of a Crate
.
Attributes
size[R]
Public Class Methods
new(hash)
click to toggle source
Default initializer for the Item
object.
@param [Hash] hash an item hash. @return [CrateAPI::Item] a fully initialized Item
object.
Calls superclass method
CrateAPI::CrateObject::new
# File lib/crate_api/item.rb, line 13 def initialize(hash) super(hash) @size = hash["size"] end
Public Instance Methods
destroy()
click to toggle source
Will destroy the given file.
@return [nil] this method should return nil if there are no issues. @raise [FileDestroyError] an error and message describing what happened.
# File lib/crate_api/item.rb, line 22 def destroy response = JSON.parse(CrateAPI::Base.call("#{CrateAPI::Base::ITEMS_URL}/#{CrateAPI::Items::ITEM_ACTIONS[:destroy] % ["#{self.id}"]}", :post)) raise FileDestroyError, response["message"] unless response["status"] != "failure" end