Class: Mangdown::Mangareader
Instance Attribute Summary
#root
Instance Method Summary
collapse
#is_chapter?, #is_manga?, #is_page?, #manga_chapters, #manga_list, #type
Constructor Details
#initialize(uri, doc) ⇒ Mangareader
Returns a new instance of Mangareader.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/mangdown/adapter/mangareader.rb', line 5
def initialize(uri, doc)
super
@root ||= 'http://www.mangareader.net'
@manga_list_css = 'ul.series_alpha li a'
@manga_name_css = 'h2.aname'
@chapter_list_css = 'div#chapterlist td a'
@manga_list_uri = "#{@root}/alphabetical"
@manga_link_prefix = @root
@reverse_chapters = false
@manga_uri_regex =
/#{@root}(\/\d+)?(\/[^\/]+)(\.html)?/i
@chapter_uri_regex =
/#{@root}(\/[^\/]+){1,2}\/(\d+|chapter-\d+\.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/mangareader.rb', line 25
def build_page_uri(uri, manga, chapter, page_num)
"#{root}/#{manga.gsub(' ', '-')}/#{chapter}/#{page_num}"
end
|
#manga_name ⇒ Object
21
22
23
|
# File 'lib/mangdown/adapter/mangareader.rb', line 21
def manga_name
CGI.unescapeHTML(super)
end
|
#num_pages ⇒ Object
29
30
31
|
# File 'lib/mangdown/adapter/mangareader.rb', line 29
def num_pages
doc.css('select')[1].css('option').length
end
|
#page_image_name ⇒ Object
37
38
39
40
41
42
|
# File 'lib/mangdown/adapter/mangareader.rb', line 37
def page_image_name
page_image[:alt].sub(/([^\d]*)(\d+)(\.\w+)?$/) {
"#{Regexp.last_match[1]}" +
"#{Regexp.last_match[2].to_s.rjust(3, '0')}"
}
end
|
#page_image_src ⇒ Object
33
34
35
|
# File 'lib/mangdown/adapter/mangareader.rb', line 33
def page_image_src
page_image[:src]
end
|