class Tilia::Dav::Fs::Node

Base node-class

The node class implements the method used by both the File and the Directory classes

Attributes

path[RW]

The path to the current node

@var string

Public Class Methods

new(path) click to toggle source

Sets up the node, expects a full path name

@param string path

# File lib/tilia/dav/fs/node.rb, line 22
def initialize(path)
  @path = path
end

Public Instance Methods

last_modified() click to toggle source

Returns the last modification time, as a unix timestamp

@return int

# File lib/tilia/dav/fs/node.rb, line 51
def last_modified
  ::File.mtime(@path)
end
name() click to toggle source

Returns the name of the node

@return string

# File lib/tilia/dav/fs/node.rb, line 29
def name
  (_, name) = Http::UrlUtil.split_path(@path)
  name
end
name=(name) click to toggle source

Renames the node

@param string name The new name @return void

# File lib/tilia/dav/fs/node.rb, line 38
def name=(name)
  parent_path = Http::UrlUtil.split_path(@path).first
  new_name = Http::UrlUtil.split_path(name).second

  new_path = parent_path + '/' + new_name
  ::File.rename(@path, new_path)

  @path = new_path
end