Sha256: e79c9afe6f211cae258b55fb30670ade538433d27b70428da8cb5c5ea1276476

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

module Net
  class DAV
    # Hold items found using Net::DAV#find
    class Item
      # URI of item
      attr_reader :uri

      # Size of item if a file
      attr_reader :size

      # Type of item - :directory or :file
      attr_reader :type

      # Synonym for uri
      def url
        @uri
      end

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

      # Get content from server if needed and return as string
      def content
        return @content unless @content.nil?
        @content = @dav.get(@uri.path)
      end

      # Put content to server
      def content=(str)
        @dav.put_string(@uri.path, str)
        @content = str
      end

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

      #Properties for this item
      def propfind
        return @dav.propfind(@uri.path)
      end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
net_dav-0.5.0 lib/net/dav/item.rb
net_dav-0.4.1 lib/net/dav/item.rb
net_dav-0.4.0 lib/net/dav/item.rb