Class: Fappu::Manga

Inherits:
Object
  • Object
show all
Defined in:
lib/fappu/manga.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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
  tags = args.delete(:tags)

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

  set_tags(tags) if tags
end

Instance Attribute Details

#artistsObject

Returns the value of attribute artists.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def artists
  @artists
end

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def category
  @category
end

#comment_countObject

Returns the value of attribute comment_count.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def comment_count
  @comment_count
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def date
  @date
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def description
  @description
end

#favoritesObject

Returns the value of attribute favorites.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def favorites
  @favorites
end

#filesizeObject

Returns the value of attribute filesize.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def filesize
  @filesize
end

#imagesObject

Returns the value of attribute images.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def images
  @images
end

#languageObject

Returns the value of attribute language.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def language
  @language
end

#page_countObject

Returns the value of attribute page_count.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def page_count
  @page_count
end

#posterObject

Returns the value of attribute poster.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def poster
  @poster
end

#poster_urlObject

Returns the value of attribute poster_url.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def poster_url
  @poster_url
end

#seriesObject

Returns the value of attribute series.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def series
  @series
end

#tagsObject

Returns the value of attribute tags.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def title
  @title
end

#translatorsObject

Returns the value of attribute translators.



4
5
6
# File 'lib/fappu/manga.rb', line 4

def translators
  @translators
end

#urlObject

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_urlObject



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_urlObject



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

#pagesObject



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


30
31
32
# File 'lib/fappu/manga.rb', line 30

def related
  Fappu::Search.related(self)
end

#top_commentsObject



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