Class: ProxyFS::FS
- Inherits:
-
Object
- Object
- ProxyFS::FS
- Defined in:
- lib/proxyfs.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #entry(path) ⇒ Object
-
#initialize(tree) ⇒ FS
constructor
A new instance of FS.
Constructor Details
#initialize(tree) ⇒ FS
Returns a new instance of FS.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/proxyfs.rb', line 81 def initialize tree @tree = tree iam = self @dir = Class.new Dir do @@fs = iam def self.fs @@fs end def fs @@fs end end @file = Class.new File do @@fs = iam def self.fs @@fs end def fs @@fs end end end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
79 80 81 |
# File 'lib/proxyfs.rb', line 79 def dir @dir end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
79 80 81 |
# File 'lib/proxyfs.rb', line 79 def file @file end |
Instance Method Details
#entry(path) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/proxyfs.rb', line 110 def entry path path = Pathname.new path raise ArgumentError, 'path shall be absolute' unless path.absolute? patha = path.each_filename.to_a find = Proc.new do |patha, curdir| name = patha[0] raise Errno::ENOENT unless curdir.include? name e = curdir[name] rest_patha = patha[1..(-1)] if rest_patha.empty? e else if Hash === e find[rest_patha, e] elsif Array === e find[rest_patha, e[0].new(*e[1..(-1)])] else find[rest_patha, e] end end end find[patha, @tree] end |