Class: Panchira::KomifloResolver

Inherits:
Resolver
  • Object
show all
Defined in:
lib/panchira/resolvers/komiflo_resolver.rb

Overview

KomifloResolver resolves Komiflo. Komiflo has its API server, so we can utilize it.

Constant Summary collapse

URL_REGEXP =
/komiflo\.com(?:\/#!)?\/comics\/(\d+)/.freeze

Instance Method Summary collapse

Methods inherited from Resolver

applicable?, #fetch

Constructor Details

#initialize(url, options = nil) ⇒ KomifloResolver

Returns a new instance of KomifloResolver.



9
10
11
12
13
14
15
# File 'lib/panchira/resolvers/komiflo_resolver.rb', line 9

def initialize(url, options = nil)
  super(url, options)

  @id = url.slice(URL_REGEXP, 1)
  raw_json = URI.parse("https://api.komiflo.com/content/id/#{@id}").read('User-Agent' => user_agent)
  @json = JSON.parse(raw_json)
end