Class: Pione::Location::HTTPLocation
Constant Summary
Constants inherited
from DataLocation
DataLocation::KNOWN_ATTRS
Instance Attribute Summary
Attributes inherited from DataLocation
#path, #uri
#address
Instance Method Summary
collapse
#+, #==, #append, #as_directory, #basename, #cached?, #create, #ctime, define, #delete, #directory_entries, #dirname, #entries, #extname, #file_entries, #hash, #initialize, #inspect, #link, #local, #local?, #mkdir, #move, #mtime=, need_caching?, real_appendable?, #rebuild, #rel_entries, set_scheme, #sha1, #turn, #update, writable?, #write
#==, #hash, #initialize, #inspect, location_type
Instance Method Details
#copy(dest, option = {}) ⇒ Object
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/pione/location/http-location.rb', line 36
def copy(dest, option={})
option[:keep_mtime] = true if option[:keep_mtime].nil?
http_get {|rec| dest.write rec.body}
dest.mtime = self.mtime if option[:keep_mtime]
end
|
#directory? ⇒ Boolean
32
33
34
|
# File 'lib/pione/location/http-location.rb', line 32
def directory?
false
end
|
#exist? ⇒ Boolean
22
23
24
25
26
|
# File 'lib/pione/location/http-location.rb', line 22
def exist?
http_head {|res| true}
rescue
false
end
|
#file? ⇒ Boolean
28
29
30
|
# File 'lib/pione/location/http-location.rb', line 28
def file?
exist?
end
|
#mtime ⇒ Object
14
15
16
|
# File 'lib/pione/location/http-location.rb', line 14
def mtime
http_head {|res| Time.httpdate(res['last-modified']) }
end
|
#read ⇒ Object
10
11
12
|
# File 'lib/pione/location/http-location.rb', line 10
def read
http_get {|res| res.body}
end
|
#size ⇒ Object
18
19
20
|
# File 'lib/pione/location/http-location.rb', line 18
def size
http_head {|res| res.content_length } || read.size
end
|