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.
25 26 27 28 29 30 31 |
# File 'lib/yamd.rb', line 25 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.
23 24 25 |
# File 'lib/yamd.rb', line 23 def custom_data @custom_data end |
#manga ⇒ Object (readonly)
Returns the value of attribute manga.
23 24 25 |
# File 'lib/yamd.rb', line 23 def manga @manga end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
23 24 25 |
# File 'lib/yamd.rb', line 23 def number @number end |
#parsed_html ⇒ Object (readonly)
Returns the value of attribute parsed_html.
23 24 25 |
# File 'lib/yamd.rb', line 23 def parsed_html @parsed_html end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
23 24 25 |
# File 'lib/yamd.rb', line 23 def url @url end |
Class Method Details
.page_class ⇒ Object
52 53 54 |
# File 'lib/yamd.rb', line 52 def self.page_class fail 'This method is abstract and have to be defined in a subclass.' end |
Instance Method Details
#name ⇒ Object
37 38 39 |
# File 'lib/yamd.rb', line 37 def name fail 'This method is abstract and have to be defined in a subclass.' end |
#pages ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/yamd.rb', line 41 def pages Enumerator.new do | yielder | number = 1 pages_info.each do | page_info | parsed_html = Nokogiri::HTML(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
33 34 35 |
# File 'lib/yamd.rb', line 33 def pages_info fail 'This method is abstract and have to be defined in a subclass.' end |