Class: Rabbit::Source::URI

Inherits:
Object
  • Object
show all
Includes:
Base, LimitAccessInterval
Defined in:
lib/rabbit/source/uri.rb

Constant Summary

Constants included from LimitAccessInterval

LimitAccessInterval::MINIMUM_ACCESS_TIME

Instance Attribute Summary

Attributes included from Base

#base, #encoding, #force_modified, #tmp_base

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LimitAccessInterval

#old?

Methods included from Base

append_features, #full_path, #modified?, #old?, #open_full_path, #read, #reset, #source=, #tmp_dir_name

Constructor Details

#initialize(encoding, logger, uri) ⇒ URI

Returns a new instance of URI.



31
32
33
34
35
# File 'lib/rabbit/source/uri.rb', line 31

def initialize(encoding, logger, uri)
  @uri = ::URI.parse(uri)
  super(encoding, logger)
  @last_modified = nil
end

Class Method Details

.initial_args_descriptionObject



26
27
28
# File 'lib/rabbit/source/uri.rb', line 26

def initial_args_description
  N_("URI")
end

.new(encoding, logger, uri) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rabbit/source/uri.rb', line 14

def new(encoding, logger, uri)
  parsed_uri = ::URI.parse(uri)
  case parsed_uri.scheme
  when nil
    File.new(encoding, logger, parsed_uri.path)
  when /\Afile\z/i
    File.new(encoding, logger, uri.gsub(/\Afile:\/\//i, ""))
  else
    super
  end
end

Instance Method Details

#extensionObject



41
42
43
# File 'lib/rabbit/source/uri.rb', line 41

def extension
  extract_extension(@uri.path)
end

#need_read?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rabbit/source/uri.rb', line 37

def need_read?
  super or old?(@last_modified, :last_modified)
end