Class: Net::DAV::Item

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

Overview

Hold items found using Net::DAV#find

Defined Under Namespace

Classes: Props

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

:nodoc:



56
57
58
59
60
61
62
# File 'lib/net/dav/item.rb', line 56

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

Instance Attribute Details

#propertiesObject (readonly)

Properties holder



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

def properties
  @properties
end

#sizeObject (readonly)

Size of item if a file



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

def size
  @size
end

#typeObject (readonly)

Type of item - :directory or :file



46
47
48
# File 'lib/net/dav/item.rb', line 46

def type
  @type
end

#uriObject (readonly)

URI of item



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

def uri
  @uri
end

Instance Method Details

#contentObject

Get content from server if needed and return as string



65
66
67
68
# File 'lib/net/dav/item.rb', line 65

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

#content=(str) ⇒ Object

Put content to server



71
72
73
74
# File 'lib/net/dav/item.rb', line 71

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

#inspectObject

:nodoc:



90
91
92
# File 'lib/net/dav/item.rb', line 90

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

#propfindObject

Properties for this item



82
83
84
# File 'lib/net/dav/item.rb', line 82

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

#proppatch(xml_snippet) ⇒ Object

Proppatch item



77
78
79
# File 'lib/net/dav/item.rb', line 77

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

#to_sObject

:nodoc:



86
87
88
# File 'lib/net/dav/item.rb', line 86

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

#urlObject

Synonym for uri



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

def url
  @uri
end