class Fappu::Manga

Attributes

artists[RW]
category[RW]
comment_count[RW]
date[RW]
description[RW]
favorites[RW]
filesize[RW]
images[RW]
language[RW]
page_count[RW]
poster[RW]
poster_url[RW]
series[RW]
tags[RW]
title[RW]
translators[RW]
url[RW]

Public Class Methods

new(args) click to toggle source
# File lib/fappu/manga.rb, line 9
def initialize args
  tags = args.delete(:tags)

  args.each do |k,v|
    instance_variable_set("@#{k}",v) unless v.nil?
  end

  set_tags(tags) if tags
end

Public Instance Methods

base_api_url() click to toggle source
# 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) click to toggle source

WIP : Wait for API to be fixed

# 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() click to toggle source
# 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() click to toggle source
# 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
top_comments() click to toggle source
# 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

Private Instance Methods

comment_api_url() click to toggle source
# File lib/fappu/manga.rb, line 99
def comment_api_url
  comment_url = base_api_url
  comment_url.path += "/comments"
  comment_url.to_s
end
download_api_url() click to toggle source
# File lib/fappu/manga.rb, line 79
def download_api_url
  comment_url = base_api_url
  comment_url.path += "/download"
  comment_url.to_s
end
read_online_url() click to toggle source
# File lib/fappu/manga.rb, line 91
def read_online_url
  read_url = base_api_url
  read_url.path += '/read'
  read_url.to_s
end
set_tags(tags) click to toggle source
# File lib/fappu/manga.rb, line 85
def set_tags(tags)
  @tags = tags.collect do |tag|
    Fappu::Tag.new(name: tag['attribute'], url: tag['attribute_link'])
  end
end