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.
316 317 318 |
# File 'lib/invfs.rb', line 316 def initialize(*dirs) @dirs = dirs end |
Instance Attribute Details
#dirs ⇒ Object (readonly)
Returns the value of attribute dirs.
314 315 316 |
# File 'lib/invfs.rb', line 314 def dirs @dirs end |
Instance Method Details
#file?(lib) ⇒ Boolean
320 321 322 323 324 325 326 327 |
# File 'lib/invfs.rb', line 320 def file?(lib) dirs.each do |dir| path = File.join(dir, lib) return true if File.file?(path) end false end |
#inspect ⇒ Object
355 356 357 |
# File 'lib/invfs.rb', line 355 def inspect to_s end |
#pretty_print(q) ⇒ Object
359 360 361 362 363 364 365 366 367 |
# File 'lib/invfs.rb', line 359 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
338 339 340 341 342 343 344 345 |
# File 'lib/invfs.rb', line 338 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
329 330 331 332 333 334 335 336 |
# File 'lib/invfs.rb', line 329 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
347 348 349 |
# File 'lib/invfs.rb', line 347 def to_path %(#<#{self.class} #{dirs.map { |d| "<#{d}>" }.join(", ")}>) end |
#to_s ⇒ Object
351 352 353 |
# File 'lib/invfs.rb', line 351 def to_s to_path end |