Class: Sp2010::File
- Inherits:
-
Object
- Object
- Sp2010::File
- Defined in:
- lib/file.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
-
#is_aspx ⇒ Object
readonly
Returns the value of attribute is_aspx.
-
#is_folder ⇒ Object
readonly
Returns the value of attribute is_folder.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #dav_prop_at(prop) ⇒ Object
-
#initialize(node) ⇒ File
constructor
A new instance of File.
- #webdav_namespace ⇒ Object
Constructor Details
#initialize(node) ⇒ File
Returns a new instance of File.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/file.rb', line 8 def initialize(node) @xml = node @name = dav_prop_at("./DAV:displayname").content @url = @xml.at_xpath("./DAV:href", webdav_namespace).content @uri = Domainatrix.parse(@url) @path = @uri.path @is_aspx = name[-5..-1] == ".aspx" length = dav_prop_at("./DAV:getcontentlength").content @size = length ? length.to_i : nil isFolder = dav_prop_at("./DAV:isFolder") @is_folder = isFolder ? isFolder.content == "t" : false c = dav_prop_at("./DAV:getetag").content @etag = c.match(/^['"](.*)['"]$/)[1] @updated_at = dav_prop_at("./DAV:getlastmodified").content @created_at = dav_prop_at("./DAV:creationdate").content end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
6 7 8 |
# File 'lib/file.rb', line 6 def created_at @created_at end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
6 7 8 |
# File 'lib/file.rb', line 6 def etag @etag end |
#is_aspx ⇒ Object (readonly)
Returns the value of attribute is_aspx.
6 7 8 |
# File 'lib/file.rb', line 6 def is_aspx @is_aspx end |
#is_folder ⇒ Object (readonly)
Returns the value of attribute is_folder.
6 7 8 |
# File 'lib/file.rb', line 6 def is_folder @is_folder end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/file.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/file.rb', line 6 def path @path end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/file.rb', line 6 def size @size end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
6 7 8 |
# File 'lib/file.rb', line 6 def updated_at @updated_at end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/file.rb', line 6 def uri @uri end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/file.rb', line 6 def url @url end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
5 6 7 |
# File 'lib/file.rb', line 5 def xml @xml end |
Instance Method Details
#dav_prop_at(prop) ⇒ Object
35 36 37 |
# File 'lib/file.rb', line 35 def dav_prop_at(prop) @xml.xpath("./DAV:propstat/DAV:prop", webdav_namespace).at_xpath(prop, webdav_namespace) end |
#webdav_namespace ⇒ Object
31 32 33 |
# File 'lib/file.rb', line 31 def webdav_namespace webdav_namespace = {"DAV" => "DAV:"} end |