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.
9 10 11 |
# File 'lib/invfs/unionfs.rb', line 9 def initialize(*dirs) @dirs = dirs end |
Instance Attribute Details
#dirs ⇒ Object (readonly)
Returns the value of attribute dirs.
7 8 9 |
# File 'lib/invfs/unionfs.rb', line 7 def dirs @dirs end |
Instance Method Details
#file?(lib) ⇒ Boolean
13 14 15 16 17 18 19 20 |
# File 'lib/invfs/unionfs.rb', line 13 def file?(lib) dirs.each do |dir| path = File.join(dir, lib) return true if File.file?(path) end false end |
#inspect ⇒ Object
48 49 50 |
# File 'lib/invfs/unionfs.rb', line 48 def inspect to_s end |
#pretty_print(q) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/invfs/unionfs.rb', line 52 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
31 32 33 34 35 36 37 38 |
# File 'lib/invfs/unionfs.rb', line 31 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
22 23 24 25 26 27 28 29 |
# File 'lib/invfs/unionfs.rb', line 22 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
40 41 42 |
# File 'lib/invfs/unionfs.rb', line 40 def to_path %(#<#{self.class} #{dirs.map { |d| "<#{d}>" }.join(", ")}>) end |
#to_s ⇒ Object
44 45 46 |
# File 'lib/invfs/unionfs.rb', line 44 def to_s to_path end |