Class: KFileset::PathEntry

Inherits:
Pathname
  • Object
show all
Includes:
KLog::Logging
Defined in:
lib/k_fileset/path_entry.rb

Overview

PathEntry is a (RUBY) Pathname object with some extra properties

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PathEntry

_path_name,



15
16
17
18
19
20
21
22
23
24
# File 'lib/k_fileset/path_entry.rb', line 15

def initialize(path)
  super(path)
  # @key = realpath.to_s
  # @key = File.join(@key, '.') if pathname.ends_with?('.')
  # puts @key
  # @path_name = path_name
  @working_directory = Dir.getwd
  # @pathname = pathname
  # debug
end

Instance Attribute Details

#working_directoryObject (readonly)

unique absolute path name e.g.(/abc, /abc/.) attr_reader :key attr_reader :path_name # Pathname



10
11
12
# File 'lib/k_fileset/path_entry.rb', line 10

def working_directory
  @working_directory
end

Instance Method Details

#debugObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/k_fileset/path_entry.rb', line 47

def debug
  # puts "expand_path   : #{self.expand_path.to_s}"
  # puts "realdirpath   : #{self.realdirpath.to_s}"
  # puts "realpath      : #{self.realpath.to_s}"
  # puts "extname       : #{self.extname.to_s}"
  # puts "basename      : #{self.basename.to_s}"
  # puts "dirname       : #{self.dirname.to_s}"
  # puts "to_path       : #{self.to_path.to_s}"
  # puts "parent        : #{self.parent.to_s}"
  # log.line
  log.kv 'key', key
  log.kv 'working_directory', working_directory
  log.kv 'pathname', path

  log.kv 'to_path', to_path
  log.kv 'cleanpath', cleanpath

  # log.kv 'directory?', directory?
  # log.kv 'root?', root?
  # log.kv 'absolute?', absolute?
  # log.kv 'relative?', relative?
  # log.kv 'exist?', exist?
  # log.kv 'file?', file?
  # log.kv 'size?', size?
  # log.kv 'ftype', ftype
  # log.kv 'empty?', empty?
  # log.kv 'readable?', readable?
  # log.kv 'birthtime', birthtime
  # log.kv 'expand_path', expand_path
  # log.kv 'realdirpath', realdirpath
  # log.kv 'realpath', realpath
  # log.kv 'extname', extname
  # log.kv 'basename', basename
  # log.kv 'dirname', dirname
  # log.kv 'to_path', to_path
  # log.kv 'size', size

  log.line
end

#keyObject



26
27
28
29
30
31
32
33
34
# File 'lib/k_fileset/path_entry.rb', line 26

def key
  return @key if defined? @key

  @key = begin
    key = realpath.to_s
    key = File.join(key, '.') if basename.to_s == '.' # if pathname.ends_with?('.')
    key
  end
end

#pathObject

Realpath (is the absolute path of the entry)

The Realpath is based on the current directory at the time this entry was created def realpath

path_name.realpath(working_directory).to_s

end



43
44
45
# File 'lib/k_fileset/path_entry.rb', line 43

def path
  realpath.to_s
end