Class: Retriever::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/retriever/target.rb

Constant Summary collapse

HTTP_RE =
Regexp.new(/^http/i).freeze
DUB_DUB_DUB_DOT_RE =
Regexp.new(/^www\./i).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, file_re = nil) ⇒ Target

Returns a new instance of Target.



12
13
14
15
16
17
18
19
20
# File 'lib/retriever/target.rb', line 12

def initialize(url,file_re=nil)
  url = "http://#{url}" if (!(HTTP_RE =~ url))
  fail "Bad URL" if (!(/\./ =~ url))
  new_uri = URI(url)
  @target = new_uri.to_s
  @host = new_uri.host
  @host_re = Regexp.new(@host.sub('www.',''))
  @file_re ||= file_re
end

Instance Attribute Details

#file_re ⇒ Object (readonly)

Returns the value of attribute file_re.



10
11
12
# File 'lib/retriever/target.rb', line 10

def file_re
  @file_re
end

#host ⇒ Object (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/retriever/target.rb', line 10

def host
  @host
end

#host_re ⇒ Object (readonly)

Returns the value of attribute host_re.



10
11
12
# File 'lib/retriever/target.rb', line 10

def host_re
  @host_re
end

#source ⇒ Object (readonly)

Returns the value of attribute source.



10
11
12
# File 'lib/retriever/target.rb', line 10

def source
  @source
end

#target ⇒ Object (readonly)

Returns the value of attribute target.



10
11
12
# File 'lib/retriever/target.rb', line 10

def target
  @target
end