Class: Retriever::Target
- Inherits:
-
Object
- Object
- Retriever::Target
- Defined in:
- lib/retriever/target.rb
Constant Summary collapse
- HTTP_RE =
Regexp.new(/^http/i).freeze
Instance Attribute Summary collapse
-
#file_re ⇒ Object
readonly
Returns the value of attribute file_re.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#host_re ⇒ Object
readonly
Returns the value of attribute host_re.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(url, file_re = nil) ⇒ Target
constructor
A new instance of Target.
- #resync_target_and_return_source(url) ⇒ Object
Constructor Details
#initialize(url, file_re = nil) ⇒ Target
Returns a new instance of Target.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/retriever/target.rb', line 11 def initialize(url, file_re = nil) fail 'Bad URL' unless url.include?('.') url = "http://#{url}" unless HTTP_RE =~ url target_uri = Addressable::URI.parse(Addressable::URI.encode(url)) @target = target_uri.to_s @host = target_uri.host @host_re = Regexp.new(@host.sub('www.', '')) @file_re ||= file_re @scheme = target_uri.scheme end |
Instance Attribute Details
#file_re ⇒ Object (readonly)
Returns the value of attribute file_re.
9 10 11 |
# File 'lib/retriever/target.rb', line 9 def file_re @file_re end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/retriever/target.rb', line 9 def host @host end |
#host_re ⇒ Object (readonly)
Returns the value of attribute host_re.
9 10 11 |
# File 'lib/retriever/target.rb', line 9 def host_re @host_re end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
9 10 11 |
# File 'lib/retriever/target.rb', line 9 def scheme @scheme end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
9 10 11 |
# File 'lib/retriever/target.rb', line 9 def source @source end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
9 10 11 |
# File 'lib/retriever/target.rb', line 9 def target @target end |