Class: CrateAPI::Item
- Inherits:
-
CrateObject
- Object
- CrateObject
- CrateAPI::Item
- Defined in:
- lib/crate_api/item.rb
Overview
Item class which is used to manipulate and represent a file blob which is inside of a Crate.
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from CrateObject
Instance Method Summary collapse
-
#destroy ⇒ nil
Will destroy the given file.
-
#initialize(hash) ⇒ CrateAPI::Item
constructor
Default initializer for the Item object.
Methods inherited from CrateObject
Constructor Details
#initialize(hash) ⇒ CrateAPI::Item
Default initializer for the Item object.
13 14 15 16 |
# File 'lib/crate_api/item.rb', line 13 def initialize(hash) super(hash) @size = hash["size"] end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
8 9 10 |
# File 'lib/crate_api/item.rb', line 8 def size @size end |
Instance Method Details
#destroy ⇒ nil
Will destroy the given file.
22 23 24 25 |
# 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 |