Class: InVFS::UnionFS
Instance Attribute Summary collapse
-
#dirs ⇒ Object
readonly
Returns the value of attribute dirs.
Instance Method Summary collapse
- #file?(lib) ⇒ Boolean
-
#initialize(*dirs) ⇒ UnionFS
constructor
A new instance of UnionFS.
- #inspect ⇒ Object
- #pretty_print(q) ⇒ Object
- #read(lib) ⇒ Object
- #size(lib) ⇒ Object
- #to_path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*dirs) ⇒ UnionFS
Returns a new instance of UnionFS.
260 261 262 |
# File 'lib/invfs.rb', line 260 def initialize(*dirs) @dirs = dirs end |
Instance Attribute Details
#dirs ⇒ Object (readonly)
Returns the value of attribute dirs.
258 259 260 |
# File 'lib/invfs.rb', line 258 def dirs @dirs end |
Instance Method Details
#file?(lib) ⇒ Boolean
264 265 266 267 268 269 270 271 |
# File 'lib/invfs.rb', line 264 def file?(lib) dirs.each do |dir| path = File.join(dir, lib) return true if File.file?(path) end false end |
#inspect ⇒ Object
299 300 301 |
# File 'lib/invfs.rb', line 299 def inspect to_s end |
#pretty_print(q) ⇒ Object
303 304 305 306 307 308 309 310 311 |
# File 'lib/invfs.rb', line 303 def pretty_print(q) q.group(2, "#<#{self.class}", ">") do dirs.each_with_index do |d, i| q.text "," if i > 0 q.breakable " " d.pretty_print q end end end |
#read(lib) ⇒ Object
282 283 284 285 286 287 288 289 |
# File 'lib/invfs.rb', line 282 def read(lib) dirs.each do |dir| path = File.join(dir, lib) return File.binread(path) if File.file?(path) end raise Errno::ENOENT, lib end |
#size(lib) ⇒ Object
273 274 275 276 277 278 279 280 |
# File 'lib/invfs.rb', line 273 def size(lib) dirs.each do |dir| path = File.join(dir, lib) return File.size(path) if File.file?(path) end raise Errno::ENOENT, lib end |
#to_path ⇒ Object
291 292 293 |
# File 'lib/invfs.rb', line 291 def to_path %(#<#{self.class} #{dirs.map { |d| "<#{d}>" }.join(", ")}>) end |
#to_s ⇒ Object
295 296 297 |
# File 'lib/invfs.rb', line 295 def to_s to_path end |