Class: ChapterCrawler
- Inherits:
-
Object
- Object
- ChapterCrawler
- Defined in:
- lib/yamd.rb
Direct Known Subclasses
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.
-
#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.
42 43 44 45 46 47 48 |
# File 'lib/yamd.rb', line 42 def initialize(custom_data, chapter_page, number, manga) @custom_data = custom_data @url = custom_data[:url] @number = number @parsed_html = chapter_page @manga = manga end |
Instance Attribute Details
#custom_data ⇒ Object (readonly)
Returns the value of attribute custom_data.
40 41 42 |
# File 'lib/yamd.rb', line 40 def custom_data @custom_data end |
#manga ⇒ Object (readonly)
Returns the value of attribute manga.
40 41 42 |
# File 'lib/yamd.rb', line 40 def manga @manga end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
40 41 42 |
# File 'lib/yamd.rb', line 40 def number @number end |
#parsed_html ⇒ Object (readonly)
Returns the value of attribute parsed_html.
40 41 42 |
# File 'lib/yamd.rb', line 40 def parsed_html @parsed_html end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
40 41 42 |
# File 'lib/yamd.rb', line 40 def url @url end |
Class Method Details
.page_class ⇒ Object
69 70 71 |
# File 'lib/yamd.rb', line 69 def self.page_class fail 'This method is abstract and have to be defined in a subclass.' end |
Instance Method Details
#name ⇒ Object
54 55 56 |
# File 'lib/yamd.rb', line 54 def name fail 'This method is abstract and have to be defined in a subclass.' end |
#pages ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/yamd.rb', line 58 def pages Enumerator.new do | yielder | number = 1 pages_info.each do | page_info | parsed_html = Nokogiri::HTML(my_open(page_info[:url])) yielder.yield self.class.page_class.new(page_info, parsed_html, number, self) number += 1 end end end |
#pages_info ⇒ Object
50 51 52 |
# File 'lib/yamd.rb', line 50 def pages_info fail 'This method is abstract and have to be defined in a subclass.' end |