Class: ComicWalker::Client::License

Inherits:
Object
  • Object
show all
Defined in:
lib/comic_walker/client/license.rb

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ License

Returns a new instance of License.



9
10
11
# File 'lib/comic_walker/client/license.rb', line 9

def initialize(json)
  @json = json
end

Instance Method Details

#agreementObject



13
14
15
# File 'lib/comic_walker/client/license.rb', line 13

def agreement
  @json['agreement']
end

#get_infoObject



37
38
39
40
41
42
43
# File 'lib/comic_walker/client/license.rb', line 37

def get_info
  uri = Addressable::URI.parse(info_url)
  body = Net::HTTP.start(uri.host) do |http|
    http.get(uri.request_uri).body
  end
  JSON.parse(body)
end

#info_urlObject



21
22
23
# File 'lib/comic_walker/client/license.rb', line 21

def info_url
  agreement['url_prefix'] + agreement['info_file_name']
end

#jar_urlObject



17
18
19
# File 'lib/comic_walker/client/license.rb', line 17

def jar_url
  agreement['url_prefix'] + agreement['jar_file_name']
end

#keyObject



25
26
27
# File 'lib/comic_walker/client/license.rb', line 25

def key
  Base64.decode64(agreement['key'])
end

#with_jar(&block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/comic_walker/client/license.rb', line 29

def with_jar(&block)
  uri = Addressable::URI.parse(jar_url)
  body = Net::HTTP.start(uri.host) do |http|
    http.get(uri.request_uri).body
  end
  Zip::InputStream.open(StringIO.new(body), &block)
end