Class: MangaCrawler

Inherits:
Object
  • Object
show all
Defined in:
lib/yamd.rb

Direct Known Subclasses

FakkuCrawler, MangafoxCrawler, MangahereCrawler

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.



77
78
79
80
# File 'lib/yamd.rb', line 77

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_htmlObject

Returns the value of attribute parsed_html.



75
76
77
# File 'lib/yamd.rb', line 75

def parsed_html
  @parsed_html
end

#urlObject

Returns the value of attribute url.



75
76
77
# File 'lib/yamd.rb', line 75

def url
  @url
end

Class Method Details

.chapter_classObject



101
102
103
# File 'lib/yamd.rb', line 101

def self.chapter_class
  fail 'This method is abstract and have to be defined in a subclass.'
end

Instance Method Details

#chaptersObject



86
87
88
89
90
91
92
93
94
95
# File 'lib/yamd.rb', line 86

def chapters
  Enumerator.new do | yielder |
    number = 1
    chapters_info.each do | chapter_info |
      page = Nokogiri::HTML(my_open(chapter_info[:url]))
      yielder.yield self.class.chapter_class.new(chapter_info, page, number, self)
      number += 1
    end
  end
end

#chapters_infoObject



82
83
84
# File 'lib/yamd.rb', line 82

def chapters_info
  fail 'This method is abstract and have to be defined in a subclass.'
end

#nameObject



97
98
99
# File 'lib/yamd.rb', line 97

def name
  fail 'This method is abstract and have to be defined in a subclass.'
end