Class: Mangdown::Mangafox

Inherits:
Adapter::Base show all
Defined in:
lib/mangdown/adapter/mangafox.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) ⇒ Mangafox

Returns a new instance of Mangafox.



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

def initialize(uri, doc)
    super
  @manga_list_css        = 'div.manga_list li a'
  @chapter_list_css      = 'a.tips'
  @root                  = 'http://mangafox.me'
    @manga_list_uri        = "#{@root}/manga"
    @manga_name_css        = "#title h1"
  @manga_link_prefix     = ''
  @reverse_chapters      = true
    @manga_uri_regex       = 
      /#{@root}\/manga\/[^\/]+?\//i
    @chapter_uri_regex     = 
      /#{@manga_uri_regex}(v\d+\/)?(c\d+\/)(1\.html)/i
    @page_uri_regex        = /.+\.(png|jpg|jpeg)$/i
end

Instance Method Details

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



25
26
27
# File 'lib/mangdown/adapter/mangafox.rb', line 25

def build_page_uri(uri, manga, chapter, page_num)
  uri.sub(/\d+\.html/, "#{page_num}.html")
end

#manga_nameObject



21
22
23
# File 'lib/mangdown/adapter/mangafox.rb', line 21

def manga_name
  CGI.unescapeHTML(super.sub(/ Manga/, '').downcase).upcase
end

#num_pagesObject



29
30
31
# File 'lib/mangdown/adapter/mangafox.rb', line 29

def num_pages
  doc.css('select')[1].css('option').length - 1
end

#page_image_nameObject



37
38
39
40
# File 'lib/mangdown/adapter/mangafox.rb', line 37

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

#page_image_srcObject



33
34
35
# File 'lib/mangdown/adapter/mangafox.rb', line 33

def page_image_src
  page_image[:src]
end