Class: Vfs::Entry
- Inherits:
-
Object
show all
- Defined in:
- lib/vfs/entries/entry.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(*args) ⇒ Entry
Returns a new instance of Entry.
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/vfs/entries/entry.rb', line 5
def initialize *args
if args.size == 1 and args.first.is_a? Entry
entry = args.first
@path_cache = entry.path_cache
@driver, @path = entry.driver, entry.path
else
driver, path = *args
@path_cache = Path.new path
@driver, @path = driver, path_cache.to_s
end
raise "driver not defined!" unless self.driver
end
|
Instance Attribute Details
#driver ⇒ Object
Returns the value of attribute driver.
3
4
5
|
# File 'lib/vfs/entries/entry.rb', line 3
def driver
@driver
end
|
#path ⇒ Object
Returns the value of attribute path.
3
4
5
|
# File 'lib/vfs/entries/entry.rb', line 3
def path
@path
end
|
#path_cache ⇒ Object
Returns the value of attribute path_cache.
3
4
5
|
# File 'lib/vfs/entries/entry.rb', line 3
def path_cache
@path_cache
end
|
Instance Method Details
#==(other) ⇒ Object
113
114
115
116
|
# File 'lib/vfs/entries/entry.rb', line 113
def == other
return false unless other.is_a? Entry
driver == other.driver and path == other.path
end
|
#created_at ⇒ Object
77
|
# File 'lib/vfs/entries/entry.rb', line 77
def created_at; get :created_at end
|
#dir(path = nil) ⇒ Object
Also known as:
to_dir
29
30
31
32
33
34
35
36
|
# File 'lib/vfs/entries/entry.rb', line 29
def dir path = nil
if path
new_path = path_cache + path
Dir.new driver, new_path
else
Dir.new self
end
end
|
#dir? ⇒ Boolean
75
|
# File 'lib/vfs/entries/entry.rb', line 75
def dir?; !!get(:dir) end
|
#entry(path = nil) ⇒ Object
Also known as:
to_entry
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/vfs/entries/entry.rb', line 49
def entry path = nil
entry = if path
new_path = path_cache + path
klass = new_path.probably_dir? ? Dir : UniversalEntry
klass.new driver, new_path
else
UniversalEntry.new self
end
EntryProxy.new entry
end
|
#eql?(other) ⇒ Boolean
122
123
124
125
|
# File 'lib/vfs/entries/entry.rb', line 122
def eql? other
return false unless other.class == self.class
driver.eql?(other.driver) and path.eql?(other.path)
end
|
#file(path = nil) ⇒ Object
Also known as:
to_file
39
40
41
42
43
44
45
46
|
# File 'lib/vfs/entries/entry.rb', line 39
def file path = nil
if path
new_path = path_cache + path
File.new driver, new_path
else
File.new self
end
end
|
#file? ⇒ Boolean
76
|
# File 'lib/vfs/entries/entry.rb', line 76
def file?; !!get(:file) end
|
#get(attr_name = nil) ⇒ Object
65
66
67
68
|
# File 'lib/vfs/entries/entry.rb', line 65
def get attr_name = nil
attrs = driver.open{driver.attributes(path)}
(attr_name and attrs) ? attrs[attr_name] : attrs
end
|
#hash ⇒ Object
118
119
120
|
# File 'lib/vfs/entries/entry.rb', line 118
def hash
driver.hash + path.hash
end
|
#inspect ⇒ Object
Also known as:
to_s
108
109
110
|
# File 'lib/vfs/entries/entry.rb', line 108
def inspect
"#{driver}#{':' unless driver.to_s.empty?}#{path}"
end
|
#local? ⇒ Boolean
100
101
102
|
# File 'lib/vfs/entries/entry.rb', line 100
def local?
driver.local?
end
|
#name ⇒ Object
84
85
86
|
# File 'lib/vfs/entries/entry.rb', line 84
def name
path_cache.name
end
|
#parent ⇒ Object
21
22
23
|
# File 'lib/vfs/entries/entry.rb', line 21
def parent
Dir.new(driver, path_cache + '..')
end
|
#set(options) ⇒ Object
70
71
72
73
|
# File 'lib/vfs/entries/entry.rb', line 70
def set options
not_implemented
end
|
#tmp(&block) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/vfs/entries/entry.rb', line 88
def tmp &block
driver.open do
if block
driver.tmp do |path|
block.call Dir.new(driver, path)
end
else
Dir.new driver, driver.tmp
end
end
end
|
#updated_at ⇒ Object
78
|
# File 'lib/vfs/entries/entry.rb', line 78
def updated_at; get :updated_at end
|