Class: Net::DAV::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/net/dav/item.rb

Overview

Hold items found using Net::DAV#find

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dav, uri, type, size) ⇒ Item

:nodoc:



19
20
21
22
23
24
# File 'lib/net/dav/item.rb', line 19

def initialize(dav, uri, type, size) #:nodoc:
  @uri = uri
  @size = size.to_i rescue nil
  @type = type
  @dav = dav
end

Instance Attribute Details

#sizeObject (readonly)

Size of item if a file



9
10
11
# File 'lib/net/dav/item.rb', line 9

def size
  @size
end

#typeObject (readonly)

Type of item - :directory or :file



12
13
14
# File 'lib/net/dav/item.rb', line 12

def type
  @type
end

#uriObject (readonly)

URI of item



6
7
8
# File 'lib/net/dav/item.rb', line 6

def uri
  @uri
end

Instance Method Details

#contentObject

Get content from server if needed and return as string



27
28
29
30
# File 'lib/net/dav/item.rb', line 27

def content
  return @content unless @content.nil?
  @content = @dav.get(@uri.path)
end

#content=(str) ⇒ Object

Put content to server



33
34
35
36
# File 'lib/net/dav/item.rb', line 33

def content=(str)
  @dav.put_string(@uri.path, str)
  @content = str
end

#inspectObject

:nodoc:



52
53
54
# File 'lib/net/dav/item.rb', line 52

def inspect #:nodoc:
  "#<Net::DAV::Item URL:#{@uri.to_s} type:#{@type}>"
end

#propfindObject

Properties for this item



44
45
46
# File 'lib/net/dav/item.rb', line 44

def propfind
  return @dav.propfind(@uri.path)
end

#proppatch(xml_snippet) ⇒ Object

Proppatch item



39
40
41
# File 'lib/net/dav/item.rb', line 39

def proppatch(xml_snippet)
  @dav.proppatch(@uri.path,xml_snippet)
end

#to_sObject

:nodoc:



48
49
50
# File 'lib/net/dav/item.rb', line 48

def to_s #:nodoc:
  "#<Net::DAV::Item URL:#{@uri.to_s} type:#{@type}>"
end

#urlObject

Synonym for uri



15
16
17
# File 'lib/net/dav/item.rb', line 15

def url
  @uri
end