Sha256: 0b852bcf026d94074af8b28f5a2ee792da2a68a0f5b1203e99a30a280df9259b
Contents?: true
Size: 535 Bytes
Versions: 12
Compression:
Stored size: 535 Bytes
Contents
module Gitdocs class Docfile attr_accessor :parent attr_reader :path, :name def initialize(path) @path = path @parent = File.dirname(path) @name = File.basename(path) end # within?("parent", "/root/path") => "/root/path/parent" def within?(dir, root) expanded_root = File.expand_path(dir, root) File.expand_path(@parent, root) == expanded_root || File.expand_path(@path, root).include?(expanded_root) end def dir? File.directory?(@path) end end end
Version data entries
12 entries across 12 versions & 2 rubygems