Class: PageCrawler

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

Direct Known Subclasses

FakkuPage, HentaiCafePage, MangafoxPage, MangaherePage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(custom_data, parsed_html, number, chapter) ⇒ PageCrawler

Returns a new instance of PageCrawler.



46
47
48
49
50
51
52
53
# File 'lib/yamd.rb', line 46

def initialize(custom_data, parsed_html, number, chapter)
  @custom_data = custom_data
  @url = custom_data[:url]
  @uri = Addressable::URI.heuristic_parse(url)
  @parsed_html = parsed_html
  @number = number
  @chapter = chapter
end

Instance Attribute Details

#chapterObject (readonly)

Returns the value of attribute chapter.



44
45
46
# File 'lib/yamd.rb', line 44

def chapter
  @chapter
end

#custom_dataObject (readonly)

Returns the value of attribute custom_data.



44
45
46
# File 'lib/yamd.rb', line 44

def custom_data
  @custom_data
end

#numberObject (readonly)

Returns the value of attribute number.



44
45
46
# File 'lib/yamd.rb', line 44

def number
  @number
end

#parsed_htmlObject (readonly)

Returns the value of attribute parsed_html.



44
45
46
# File 'lib/yamd.rb', line 44

def parsed_html
  @parsed_html
end

#uriObject (readonly)

Returns the value of attribute uri.



44
45
46
# File 'lib/yamd.rb', line 44

def uri
  @uri
end

#urlObject (readonly)

Returns the value of attribute url.



44
45
46
# File 'lib/yamd.rb', line 44

def url
  @url
end

Instance Method Details

#clean_image_urlObject



59
60
61
# File 'lib/yamd.rb', line 59

def clean_image_url
  @uri.join(image_url).normalize.to_s
end

#image_urlObject



55
56
57
# File 'lib/yamd.rb', line 55

def image_url
  fail 'This method is abstract and have to be defined in a subclass.'
end