Class: Mangdown::Wiemanga

Inherits:
Adapter::Base show all
Defined in:
lib/mangdown/adapter/wiemanga.rb

Instance Attribute Summary

Attributes inherited from Adapter::Base

#root

Instance Method Summary collapse

Methods inherited from Adapter::Base

#is_chapter?, #is_manga?, #is_page?, #manga_chapters, #manga_list, #type

Constructor Details

#initialize(uri, doc) ⇒ Wiemanga

Returns a new instance of Wiemanga.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mangdown/adapter/wiemanga.rb', line 5

def initialize(uri, doc)
    super
	@root                  = 'http://www.wiemanga.com'
    @manga_list_uri        = 
      "#{@root}/search/?name_sel=contain&author_sel=contain" +
      "&completed_series=either"
    @manga_name_css        = '.bookmessagebox h1'
	@manga_list_css        = 'a.resultbookname'
	@chapter_list_css      = 
      '.chapterlist tr:not(:first-child) .col1 a'
	@manga_link_prefix     = '' 
	@reverse_chapters      = true
    @manga_uri_regex       = /#{@root}\/manga\/([^\/]+)(\.html)?/i
    @chapter_uri_regex     = 
      /#{@root}\/chapter\/([^\/]+)\/(\d+)(\/|\.html)?/i
    @page_uri_regex        = /.+\.(png|jpg|jpeg)$/i
end

Instance Method Details

#build_page_uri(uri, manga, chapter, page_num) ⇒ Object



27
28
29
# File 'lib/mangdown/adapter/wiemanga.rb', line 27

def build_page_uri(uri, manga, chapter, page_num)
  "#{uri}-#{page_num}.html"
end

#manga_nameObject



23
24
25
# File 'lib/mangdown/adapter/wiemanga.rb', line 23

def manga_name
  super.sub(/ Manga$/, "")
end

#num_pagesObject



31
32
33
# File 'lib/mangdown/adapter/wiemanga.rb', line 31

def num_pages
  doc.css('select#page')[0].css('option').length
end

#page_image_nameObject



39
40
41
42
# File 'lib/mangdown/adapter/wiemanga.rb', line 39

def page_image_name
  doc.css('select#page')[0].css('option[selected]')[0]
    .text.rjust(3, '0')
end

#page_image_srcObject



35
36
37
# File 'lib/mangdown/adapter/wiemanga.rb', line 35

def page_image_src
  page_image[:src]
end