Class: ActiveSP::File
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #content_size ⇒ Object
- #content_type ⇒ Object
- #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
#content_size ⇒ Object
51 52 53 |
# File 'lib/activesp/file.rb', line 51 def content_size head_data["content-length"].to_i end |
#content_type ⇒ Object
47 48 49 |
# File 'lib/activesp/file.rb', line 47 def content_type head_data["content-type"] end |
#data ⇒ Object
43 44 45 |
# File 'lib/activesp/file.rb', line 43 def data @item.list.site.connection.fetch(@url).body end |
#destroy ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/activesp/file.rb', line 55 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 @item.clear_cache_for(:attachment_urls) 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
70 71 72 |
# File 'lib/activesp/file.rb', line 70 def to_s "#<ActiveSP::File url=#{@url}>" end |