Class: ActiveSP::File
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #data ⇒ Object
- #destroy ⇒ Object
- #file_name ⇒ Object
-
#initialize(item, url, destroyable) ⇒ File
constructor
A new instance of File.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(item, url, destroyable) ⇒ File
Returns a new instance of File.
34 35 36 37 |
# File 'lib/activesp/file.rb', line 34 def initialize(item, url, destroyable) @item, @url, @destroyable = item, url, destroyable @site = @item.list.site end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
32 33 34 |
# File 'lib/activesp/file.rb', line 32 def url @url end |
Instance Method Details
#data ⇒ Object
43 44 45 |
# File 'lib/activesp/file.rb', line 43 def data @item.list.site.connection.fetch(@url).body end |
#destroy ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/activesp/file.rb', line 47 def destroy if @destroyable result = call("Lists", "delete_attachment", "listName" => @item.list.id, "listItemID" => @item.ID, "url" => @url) if delete_result = result.xpath("//sp:DeleteAttachmentResponse", NS).first self else raise "file could not be deleted" end else raise TypeError, "this file cannot be destroyed" end end |
#file_name ⇒ Object
39 40 41 |
# File 'lib/activesp/file.rb', line 39 def file_name ::File.basename(@url) end |
#to_s ⇒ Object Also known as: inspect
61 62 63 |
# File 'lib/activesp/file.rb', line 61 def to_s "#<ActiveSP::File url=#{@url}>" end |