Class: Pione::Location::HTTPLocation

Inherits:
DataLocation show all
Defined in:
lib/pione/location/http-location.rb

Direct Known Subclasses

HTTPSLocation

Constant Summary

Constants inherited from DataLocation

DataLocation::KNOWN_ATTRS

Instance Attribute Summary

Attributes inherited from DataLocation

#path, #uri

Attributes inherited from BasicLocation

#address

Instance Method Summary collapse

Methods inherited from DataLocation

#+, #==, #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

Methods inherited from BasicLocation

#==, #hash, #initialize, #inspect, location_type

Constructor Details

This class inherits a constructor from Pione::Location::DataLocation

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={})
  # setup options
  option[:keep_mtime] = true if option[:keep_mtime].nil?

  # copy
  http_get {|rec| dest.write rec.body}

  # modify mtime
  dest.mtime = self.mtime if option[:keep_mtime]
end

#directory?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/pione/location/http-location.rb', line 32

def directory?
  false
end

#exist?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/pione/location/http-location.rb', line 28

def file?
  exist?
end

#mtimeObject



14
15
16
# File 'lib/pione/location/http-location.rb', line 14

def mtime
  http_head {|res| Time.httpdate(res['last-modified']) }
end

#readObject



10
11
12
# File 'lib/pione/location/http-location.rb', line 10

def read
  http_get {|res| res.body}
end

#sizeObject



18
19
20
# File 'lib/pione/location/http-location.rb', line 18

def size
  http_head {|res| res.content_length } || read.size
end