Sha256: 787aa7b67467961e5dc1de9a63d0421d4d54e6b0d077f3138308df80f653675f
Contents?: true
Size: 892 Bytes
Versions: 12
Compression:
Stored size: 892 Bytes
Contents
module SmallCage class DocumentPath attr_reader :root, :uri, :path def initialize(root, path) @root = Pathname.new(root).realpath; @path = Pathname.new(path) if @path.exist? @path = @path.realpath else @path = @path.cleanpath end if @path.to_s[0...@root.to_s.length] != @root.to_s raise "Illegal path: #{path.to_s}" end if @path == @root @uri = "/" else @uri = @path.to_s[@root.to_s.length .. -1] end end def smc? return @path.extname == ".smc" end def outfile return nil unless smc? return self.class.new(@root, @path.to_s[0 .. -5]) end def outuri return nil unless smc? return uri[0 .. -5] end def self.to_uri(root, path) return self.new(root,path).uri end end end
Version data entries
12 entries across 12 versions & 2 rubygems