Class: MangaCrawler
- Inherits:
-
Object
- Object
- MangaCrawler
- Defined in:
- lib/yamd.rb
Direct Known Subclasses
FakkuCrawler, HentaiCafeCrawler, MangafoxCrawler, MangahereCrawler
Instance Attribute Summary collapse
-
#parsed_html ⇒ Object
Returns the value of attribute parsed_html.
-
#uri ⇒ Object
Returns the value of attribute uri.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #chapters ⇒ Object
- #chapters_info ⇒ Object
-
#initialize(manga_main_page_url) ⇒ MangaCrawler
constructor
A new instance of MangaCrawler.
- #name ⇒ Object
Constructor Details
#initialize(manga_main_page_url) ⇒ MangaCrawler
Returns a new instance of MangaCrawler.
106 107 108 109 110 |
# File 'lib/yamd.rb', line 106 def initialize(manga_main_page_url) @url = manga_main_page_url @uri = Addressable::URI.heuristic_parse(url) @parsed_html = Nokogiri::HTML(my_open(manga_main_page_url)) end |
Instance Attribute Details
#parsed_html ⇒ Object
Returns the value of attribute parsed_html.
104 105 106 |
# File 'lib/yamd.rb', line 104 def parsed_html @parsed_html end |
#uri ⇒ Object
Returns the value of attribute uri.
104 105 106 |
# File 'lib/yamd.rb', line 104 def uri @uri end |
#url ⇒ Object
Returns the value of attribute url.
104 105 106 |
# File 'lib/yamd.rb', line 104 def url @url end |
Class Method Details
.chapter_class ⇒ Object
134 135 136 |
# File 'lib/yamd.rb', line 134 def self.chapter_class fail 'This method is abstract and have to be defined in a subclass.' end |
Instance Method Details
#chapters ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/yamd.rb', line 116 def chapters Enumerator.new do | yielder | number = 1 chapters_info.each do | chapter_info | # fix the url to be absolute full_url = @uri.join(chapter_info[:url]).to_s chapter_info[:url] = full_url page = Nokogiri::HTML(my_open(full_url)) yielder.yield self.class.chapter_class.new(chapter_info, page, number, self) number += 1 end end end |
#chapters_info ⇒ Object
112 113 114 |
# File 'lib/yamd.rb', line 112 def chapters_info fail 'This method is abstract and have to be defined in a subclass.' end |
#name ⇒ Object
130 131 132 |
# File 'lib/yamd.rb', line 130 def name fail 'This method is abstract and have to be defined in a subclass.' end |