Class: ElFinderS3::S3Pathname
Instance Attribute Summary collapse
Attributes inherited from Pathname
#path, #root
Instance Method Summary
collapse
Methods inherited from Pathname
#absolute?, #basename, #basename_sans_extension, #child_directories, #children, #dirname, #duplicate, #extname, #files, #fullpath, #is_root?, #outside_of_root?, #relative?, #relative_to, #to_s, #unique
Constructor Details
#initialize(adapter, list_entry_or_name, attrs = {}) ⇒ S3Pathname
Returns a new instance of S3Pathname.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 5
def initialize(adapter, list_entry_or_name, attrs = {})
@adapter = adapter
if list_entry_or_name.is_a? ElFinderS3::S3Pathname
super(list_entry_or_name.to_s)
self.attrs = list_entry_or_name.attrs
elsif list_entry_or_name.is_a? Aws::S3::Types::Object
super(list_entry_or_name[:key])
@size = list_entry_or_name[:size]
@type = :file
elsif list_entry_or_name.is_a? Aws::S3::Types::CommonPrefix
name = list_entry_or_name[:prefix]
super(name)
@size = 0
@type = :directory
else
super(list_entry_or_name)
self.attrs = attrs
end
end
|
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
3
4
5
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 3
def adapter
@adapter
end
|
Instance Method Details
#+(other) ⇒ Object
26
27
28
29
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 26
def +(other)
other = S3Pathname.new(adapter, other) unless S3Pathname === other
S3Pathname.new(adapter, plus(@path, other.to_s), other.attrs)
end
|
#atime ⇒ Object
45
46
47
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 45
def atime
mtime
end
|
#attrs ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 31
def attrs
{
type: @type,
time: @time,
size: @size
}
end
|
#attrs=(val) ⇒ Object
39
40
41
42
43
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 39
def attrs=(val)
@time = val[:time]
@type = val[:type]
@size = val[:size]
end
|
#cleanpath ⇒ Object
57
58
59
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 57
def cleanpath
self
end
|
#ctime ⇒ Object
49
50
51
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 49
def ctime
mtime
end
|
#directory? ⇒ Boolean
65
66
67
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 65
def directory?
type == :directory
end
|
#executable? ⇒ Boolean
138
139
140
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 138
def executable?
false
end
|
#exist? ⇒ Boolean
61
62
63
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 61
def exist?
adapter.exist?(self)
end
|
#file? ⇒ Boolean
81
82
83
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 81
def file?
type == :file
end
|
#ftype ⇒ Object
89
90
91
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 89
def ftype
type.to_s
end
|
#mkdir ⇒ Object
115
116
117
118
119
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 115
def mkdir
adapter.mkdir(self)
@type = :directory
@size = 0
end
|
#mtime ⇒ Object
53
54
55
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 53
def mtime
@time ||= adapter.mtime(self)
end
|
#pipe? ⇒ Boolean
162
163
164
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 162
def pipe?
false
end
|
#read ⇒ Object
129
130
131
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 129
def read
adapter.retrieve(self)
end
|
#readable? ⇒ Boolean
69
70
71
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 69
def readable?
true
end
|
#realpath ⇒ Object
85
86
87
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 85
def realpath
self
end
|
#rename(to) ⇒ Object
111
112
113
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 111
def rename(to)
adapter.rename(self, to)
end
|
#rmdir ⇒ Object
121
122
123
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 121
def rmdir
adapter.rmdir(self)
end
|
#size ⇒ Object
101
102
103
104
105
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 101
def size
unless @type == :directory
@size ||= adapter.size(self)
end
end
|
#symlink? ⇒ Boolean
77
78
79
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 77
def symlink?
false
end
|
#to_file_prefix_s ⇒ Object
156
157
158
159
160
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 156
def to_file_prefix_s
result = to_prefix_s
result[-1] = '' unless result[-1] != '/'
result
end
|
#to_prefix_s ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 142
def to_prefix_s
prefix_s = cleanpath.to_s
if prefix_s == '/'
return ''
elsif prefix_s[0] == '/'
prefix_s[0] = ''
end
if prefix_s[prefix_s.size-1] != '/'
prefix_s = prefix_s + '/'
end
prefix_s
end
|
#touch ⇒ Object
107
108
109
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 107
def touch
adapter.touch(self)
end
|
#type ⇒ Object
93
94
95
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 93
def type
@type ||= adapter.path_type(self)
end
|
#type=(value) ⇒ Object
97
98
99
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 97
def type=(value)
@type = value
end
|
#unlink ⇒ Object
125
126
127
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 125
def unlink
adapter.delete(self)
end
|
#writable? ⇒ Boolean
73
74
75
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 73
def writable?
true
end
|
#write(content) ⇒ Object
133
134
135
136
|
# File 'lib/el_finder_s3/s3_pathname.rb', line 133
def write(content)
adapter.store(self, content)
@size = nil
end
|