Class: ChapterCrawler
- Inherits:
-
Object
- Object
- ChapterCrawler
- Defined in:
- lib/yamd.rb
Direct Known Subclasses
FakkuChapter, HentaiCafeChapter, MangafoxChapter, MangahereChapter
Instance Attribute Summary collapse
-
#custom_data ⇒ Object
readonly
Returns the value of attribute custom_data.
-
#manga ⇒ Object
readonly
Returns the value of attribute manga.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#parsed_html ⇒ Object
readonly
Returns the value of attribute parsed_html.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(custom_data, chapter_page, number, manga) ⇒ ChapterCrawler
constructor
A new instance of ChapterCrawler.
- #name ⇒ Object
- #pages ⇒ Object
- #pages_info ⇒ Object
Constructor Details
#initialize(custom_data, chapter_page, number, manga) ⇒ ChapterCrawler
Returns a new instance of ChapterCrawler.
67 68 69 70 71 72 73 74 |
# File 'lib/yamd.rb', line 67 def initialize(custom_data, chapter_page, number, manga) @custom_data = custom_data @url = custom_data[:url] @uri = Addressable::URI.heuristic_parse(url) @number = number @parsed_html = chapter_page @manga = manga end |
Instance Attribute Details
#custom_data ⇒ Object (readonly)
Returns the value of attribute custom_data.
65 66 67 |
# File 'lib/yamd.rb', line 65 def custom_data @custom_data end |
#manga ⇒ Object (readonly)
Returns the value of attribute manga.
65 66 67 |
# File 'lib/yamd.rb', line 65 def manga @manga end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
65 66 67 |
# File 'lib/yamd.rb', line 65 def number @number end |
#parsed_html ⇒ Object (readonly)
Returns the value of attribute parsed_html.
65 66 67 |
# File 'lib/yamd.rb', line 65 def parsed_html @parsed_html end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
65 66 67 |
# File 'lib/yamd.rb', line 65 def uri @uri end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
65 66 67 |
# File 'lib/yamd.rb', line 65 def url @url end |
Class Method Details
.page_class ⇒ Object
98 99 100 |
# File 'lib/yamd.rb', line 98 def self.page_class fail 'This method is abstract and have to be defined in a subclass.' end |
Instance Method Details
#name ⇒ Object
80 81 82 |
# File 'lib/yamd.rb', line 80 def name fail 'This method is abstract and have to be defined in a subclass.' end |
#pages ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/yamd.rb', line 84 def pages Enumerator.new do | yielder | number = 1 pages_info.each do | page_info | # fix the url to be absolute full_url = @uri.join(page_info[:url]).to_s page_info[:url] = full_url parsed_html = Nokogiri::HTML(my_open(full_url)) yielder.yield self.class.page_class.new(page_info, parsed_html, number, self) number += 1 end end end |
#pages_info ⇒ Object
76 77 78 |
# File 'lib/yamd.rb', line 76 def pages_info fail 'This method is abstract and have to be defined in a subclass.' end |