Class: MangaCrawler
- Inherits:
-
Object
show all
- Defined in:
- lib/yamd.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(manga_main_page_url) ⇒ MangaCrawler
Returns a new instance of MangaCrawler.
60
61
62
63
|
# File 'lib/yamd.rb', line 60
def initialize(manga_main_page_url)
@url = manga_main_page_url
@parsed_html = Nokogiri::HTML(open(manga_main_page_url))
end
|
Instance Attribute Details
#parsed_html ⇒ Object
Returns the value of attribute parsed_html.
58
59
60
|
# File 'lib/yamd.rb', line 58
def parsed_html
@parsed_html
end
|
#url ⇒ Object
Returns the value of attribute url.
58
59
60
|
# File 'lib/yamd.rb', line 58
def url
@url
end
|
Class Method Details
.chapter_class ⇒ Object
84
85
86
|
# File 'lib/yamd.rb', line 84
def self.chapter_class
fail 'This method is abstract and have to be defined in a subclass.'
end
|
Instance Method Details
#chapters ⇒ Object
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/yamd.rb', line 69
def chapters
Enumerator.new do | yielder |
number = 1
chapters_info.each do | chapter_info |
page = Nokogiri::HTML(open(chapter_info[:url]))
yielder.yield self.class.chapter_class.new(chapter_info, page, number, self)
number += 1
end
end
end
|
#chapters_info ⇒ Object
65
66
67
|
# File 'lib/yamd.rb', line 65
def chapters_info
fail 'This method is abstract and have to be defined in a subclass.'
end
|
#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
|