class Vpim::Agent::Path
Public Class Methods
new(uri, base = "")
click to toggle source
URI is the uri being queried, base is where this path is mounted under?
# File lib/vpim/agent/calendars.rb, line 36 def initialize(uri, base = "") @uri = URI.parse(uri.to_s) #pp [uri, base, @uri] if @uri.path.size == 0 @uri.path = "/" end @path = Path.split_path(@uri.path) @base = base.to_str @mark = 0 @base.split.size.times{ shift } end
split_path(path)
click to toggle source
# File lib/vpim/agent/calendars.rb, line 26 def self.split_path(path) begin path = path.to_ary rescue NameError path = path.split("/") end path.map{|w| CGI.unescape(w)} end
Public Instance Methods
append(name, scheme = nil)
click to toggle source
# File lib/vpim/agent/calendars.rb, line 64 def append(name, scheme = nil) uri = @uri.dup uri.path += "/" + CGI.escape(name) if scheme uri.scheme = scheme end uri end
prefix(len = nil)
click to toggle source
# File lib/vpim/agent/calendars.rb, line 73 def prefix(len = nil) len ||= @mark @path[0, len].map{|p| CGI.escape(p)}.join("/") + "/" end
shift()
click to toggle source
TODO - call this next
# File lib/vpim/agent/calendars.rb, line 58 def shift if @path[@mark] @path[@mark += 1] end end
to_path()
click to toggle source
# File lib/vpim/agent/calendars.rb, line 53 def to_path self end
uri()
click to toggle source
# File lib/vpim/agent/calendars.rb, line 49 def uri @uri.to_s end