Class: Linkey::CheckResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, base, reg, file_name) ⇒ CheckResponse

Returns a new instance of CheckResponse.



11
12
13
14
15
16
# File 'lib/linkey.rb', line 11

def initialize(url, base, reg, file_name)
  @url = url
  @base = base
  @reg = reg
  @file_name = file_name
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



9
10
11
# File 'lib/linkey.rb', line 9

def base
  @base
end

#file_nameObject

Returns the value of attribute file_name.



9
10
11
# File 'lib/linkey.rb', line 9

def file_name
  @file_name
end

#regObject

Returns the value of attribute reg.



9
10
11
# File 'lib/linkey.rb', line 9

def reg
  @reg
end

#urlObject

Returns the value of attribute url.



9
10
11
# File 'lib/linkey.rb', line 9

def url
  @url
end

Instance Method Details



18
19
20
21
# File 'lib/linkey.rb', line 18

def check_links
  links_list = File.read(file_name).split(",")
  links(links_list)
end


23
24
25
26
27
# File 'lib/linkey.rb', line 23

def links(links)
  links.each do |url_links|
    scan(url_links)
  end
end

#scan(page_links) ⇒ Object



29
30
31
32
# File 'lib/linkey.rb', line 29

def scan(page_links)
  urls = page_links.scan(/^#{Regexp.quote(reg)}(?:|.+)?$/)
  Getter.new(urls, base).check
end