Class: MangaedenApi::Manga

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

Overview

Class containing all manga informations.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manga_info, manga_id = nil) ⇒ Manga

Returns a new instance of Manga.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/mangaeden_api/manga.rb', line 10

def initialize(manga_info, manga_id = nil)
  @manga_id = manga_id
  @aka = manga_info['aka']
  @aka_alias = manga_info['aka-alias']
  @alias = manga_info['alias']
  @artist = manga_info['artist']
  @artist_kw = manga_info['artist_kw']
  @author = manga_info['author']
  @author_kw = manga_info['author_kw']
  @categories = manga_info['categories']
  @chapters_len = manga_info['chapters_len']
  @chapters_info = manga_info['chapters']
  @created = manga_info['created']
  @description = manga_info['description']
  @hits = manga_info['hits']
  @image = MangaedenApi::IMAGE_HOST + manga_info['image']
  @language = manga_info['language']
  @last_chapter_date = manga_info['last_chapter_date']
  @random = manga_info['random']
  @released = manga_info['release']
  @starts_with = manga_info['startsWith']
  @status = manga_info['status']
  @title = manga_info['title']
  @title_kw = manga_info['title_kw']
  @type = manga_info['type']
  @updated_keywords = manga_info['updatedKeywords']
end

Instance Attribute Details

#akaObject

Returns the value of attribute aka.



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

def aka
  @aka
end

#aka_aliasObject

Returns the value of attribute aka_alias.



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

def aka_alias
  @aka_alias
end

#aliasObject

Returns the value of attribute alias.



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

def alias
  @alias
end

#artistObject

Returns the value of attribute artist.



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

def artist
  @artist
end

#artist_kwObject

Returns the value of attribute artist_kw.



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

def artist_kw
  @artist_kw
end

#authorObject

Returns the value of attribute author.



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

def author
  @author
end

#author_kwObject

Returns the value of attribute author_kw.



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

def author_kw
  @author_kw
end

#categoriesObject

Returns the value of attribute categories.



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

def categories
  @categories
end

#chapters_infoObject

Returns the value of attribute chapters_info.



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

def chapters_info
  @chapters_info
end

#chapters_lenObject

Returns the value of attribute chapters_len.



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

def chapters_len
  @chapters_len
end

#createdObject

Returns the value of attribute created.



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

def created
  @created
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#hitsObject

Returns the value of attribute hits.



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

def hits
  @hits
end

#imageObject

Returns the value of attribute image.



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

def image
  @image
end

#languageObject

Returns the value of attribute language.



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

def language
  @language
end

#last_chapter_dateObject

Returns the value of attribute last_chapter_date.



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

def last_chapter_date
  @last_chapter_date
end

#manga_idObject

Returns the value of attribute manga_id.



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

def manga_id
  @manga_id
end

#randomObject

Returns the value of attribute random.



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

def random
  @random
end

#releasedObject

Returns the value of attribute released.



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

def released
  @released
end

#starts_withObject

Returns the value of attribute starts_with.



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

def starts_with
  @starts_with
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#title_kwObject

Returns the value of attribute title_kw.



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

def title_kw
  @title_kw
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#updated_keywordsObject

Returns the value of attribute updated_keywords.



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

def updated_keywords
  @updated_keywords
end

Class Method Details

.search(title) ⇒ Object

Search for mangas with the specified title (case-insensitive) and return an array of manga objects



40
41
42
43
44
45
46
47
48
49
# File 'lib/mangaeden_api/manga.rb', line 40

def self.search(title)
  manga_list = MangaedenApi::Mangaeden.get_manga_list.select do |m|
    m['t'].downcase == title.downcase
  end
  mangas = []
  manga_list.each do |m|
    mangas << MangaedenApi::Mangaeden.get_manga_info(m['i'])
  end
  mangas
end

Instance Method Details

#chaptersObject

Return Chapter objects



52
53
54
55
56
57
58
# File 'lib/mangaeden_api/manga.rb', line 52

def chapters
  chapters = []
  @chapters_info.each do |c|
    chapters << MangaedenApi::Mangaeden.get_chapter_images(c)
  end
  chapters
end