Class: Fappu::Manga
- Inherits:
-
Object
- Object
- Fappu::Manga
- Defined in:
- lib/fappu/manga.rb
Instance Attribute Summary collapse
-
#artists ⇒ Object
Returns the value of attribute artists.
-
#category ⇒ Object
Returns the value of attribute category.
-
#comment_count ⇒ Object
Returns the value of attribute comment_count.
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#favorites ⇒ Object
Returns the value of attribute favorites.
-
#filesize ⇒ Object
Returns the value of attribute filesize.
-
#images ⇒ Object
Returns the value of attribute images.
-
#language ⇒ Object
Returns the value of attribute language.
-
#page_count ⇒ Object
Returns the value of attribute page_count.
-
#poster ⇒ Object
Returns the value of attribute poster.
-
#poster_url ⇒ Object
Returns the value of attribute poster_url.
-
#series ⇒ Object
Returns the value of attribute series.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
-
#translators ⇒ Object
Returns the value of attribute translators.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #base_api_url ⇒ Object
-
#comments(page = 1) ⇒ Object
WIP : Wait for API to be fixed.
- #download_url ⇒ Object
-
#initialize(args) ⇒ Manga
constructor
A new instance of Manga.
- #pages ⇒ Object
- #related ⇒ Object
- #top_comments ⇒ Object
Constructor Details
#initialize(args) ⇒ Manga
Returns a new instance of Manga.
9 10 11 12 13 14 15 16 17 |
# File 'lib/fappu/manga.rb', line 9 def initialize args = args.delete(:tags) args.each do |k,v| instance_variable_set("@#{k}",v) unless v.nil? end () if end |
Instance Attribute Details
#artists ⇒ Object
Returns the value of attribute artists.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def artists @artists end |
#category ⇒ Object
Returns the value of attribute category.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def category @category end |
#comment_count ⇒ Object
Returns the value of attribute comment_count.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def comment_count @comment_count end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def description @description end |
#favorites ⇒ Object
Returns the value of attribute favorites.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def favorites @favorites end |
#filesize ⇒ Object
Returns the value of attribute filesize.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def filesize @filesize end |
#images ⇒ Object
Returns the value of attribute images.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def images @images end |
#language ⇒ Object
Returns the value of attribute language.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def language @language end |
#page_count ⇒ Object
Returns the value of attribute page_count.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def page_count @page_count end |
#poster ⇒ Object
Returns the value of attribute poster.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def poster @poster end |
#poster_url ⇒ Object
Returns the value of attribute poster_url.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def poster_url @poster_url end |
#series ⇒ Object
Returns the value of attribute series.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def series @series end |
#tags ⇒ Object
Returns the value of attribute tags.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def title @title end |
#translators ⇒ Object
Returns the value of attribute translators.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def translators @translators end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/fappu/manga.rb', line 4 def url @url end |
Instance Method Details
#base_api_url ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fappu/manga.rb', line 60 def base_api_url base_api_url = URI(url) new_host = base_api_url.host.split('.') new_host[0] = 'api' base_api_url.host = new_host.join('.') base_api_url.scheme = 'https' base_api_url end |
#comments(page = 1) ⇒ Object
WIP : Wait for API to be fixed
51 52 53 54 55 56 57 58 |
# File 'lib/fappu/manga.rb', line 51 def comments(page = 1) response = JSON.parse( URI.parse(comment_api_url + "/page/#{page}").read ) arr = response['comments'] arr.collect do |comment| Fappu::Comment.new(comment) end end |
#download_url ⇒ Object
34 35 36 37 38 39 |
# File 'lib/fappu/manga.rb', line 34 def download_url response = JSON.parse ( URI.parse(download_api_url).read ) response['downloads'].collect do |d| d['download_url'] end end |
#pages ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/fappu/manga.rb', line 41 def pages response = JSON.parse( URI.parse(read_online_url).read ) arr = response['pages'] arr.collect do |k,v| Fappu::Page.new_from_json({k => v}) end end |
#related ⇒ Object
30 31 32 |
# File 'lib/fappu/manga.rb', line 30 def Fappu::Search.(self) end |
#top_comments ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/fappu/manga.rb', line 20 def top_comments response = JSON.parse( URI.parse(comment_api_url + "/top").read ) arr = response['comments'] arr.collect do |comment| Fappu::Comment.new(comment) end end |