Module: Fappu::Search
- Defined in:
- lib/fappu/search.rb
Constant Summary collapse
- URL =
"https://api.fakku.net/manga"
Class Method Summary collapse
-
.controversial ⇒ Object
Returns an array of the most controversial mangas as Manga instances.
-
.favorites ⇒ Object
Returns an array of the most favorite’d mangas as Manga instances.
-
.latest ⇒ Object
Returns an array of the latest mangas as Manga instances.
-
.popular ⇒ Object
Returns an array of the most popular mangas as Manga instances.
-
.related(manga) ⇒ Object
Returns an array of related mangas.
- .tagged(tag) ⇒ Object
- .terms(search_terms) ⇒ Object
Class Method Details
.controversial ⇒ Object
Returns an array of the most controversial mangas as Manga instances
61 62 63 64 65 66 67 68 |
# File 'lib/fappu/search.rb', line 61 def self.controversial response = JSON.parse( URI.parse("https://api.fakku.net/manga").read ) arr = response["controversial"] arr.collect do |manga| Fappu::Manga.new(manga_parameters(manga)) end end |
.favorites ⇒ Object
Returns an array of the most favorite’d mangas as Manga instances
41 42 43 44 45 46 47 48 |
# File 'lib/fappu/search.rb', line 41 def self.favorites response = JSON.parse( URI.parse("https://api.fakku.net/manga").read ) arr = response["favorites"] arr.collect do |manga| Fappu::Manga.new(manga_parameters(manga)) end end |
.latest ⇒ Object
Returns an array of the latest mangas as Manga instances
31 32 33 34 35 36 37 38 |
# File 'lib/fappu/search.rb', line 31 def self.latest response = JSON.parse( URI.parse("https://api.fakku.net/manga").read ) arr = response["latest"] arr.collect do |manga| Fappu::Manga.new(manga_parameters(manga)) end end |
.popular ⇒ Object
Returns an array of the most popular mangas as Manga instances
51 52 53 54 55 56 57 58 |
# File 'lib/fappu/search.rb', line 51 def self.popular response = JSON.parse( URI.parse("https://api.fakku.net/manga").read ) arr = response["popular"] arr.collect do |manga| Fappu::Manga.new(manga_parameters(manga)) end end |
.related(manga) ⇒ Object
Returns an array of related mangas
71 72 73 74 75 76 77 78 |
# File 'lib/fappu/search.rb', line 71 def self.(manga) response = JSON.parse ( URI.parse(manga.base_api_url.to_s + "/related").read ) arr = response["related"] arr.collect do |m| Fappu::Manga.new(manga_parameters(m)) end end |
.tagged(tag) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fappu/search.rb', line 7 def self.tagged(tag) tag.downcase! url = "https://api.fakku.net/tags/#{tag}" response = JSON.parse( URI.parse(url).read ) arr = response["content"] arr.collect do |manga| Fappu::Manga.new(manga_parameters(manga)) end end |
.terms(search_terms) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fappu/search.rb', line 18 def self.terms(search_terms) search_terms.downcase! search_terms = URI.encode(search_terms) url = "https://api.fakku.net/search/#{search_terms}" response = JSON.parse( URI.parse(url).read ) arr = response["content"] arr.collect do |manga| Fappu::Manga.new(manga_parameters(manga)) end end |