Class: ComicWalker::Client::License
- Inherits:
-
Object
- Object
- ComicWalker::Client::License
- Defined in:
- lib/comic_walker/client/license.rb
Instance Method Summary collapse
- #agreement ⇒ Object
- #get_info ⇒ Object
- #info_url ⇒ Object
-
#initialize(json) ⇒ License
constructor
A new instance of License.
- #jar_url ⇒ Object
- #key ⇒ Object
- #with_jar(&block) ⇒ Object
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
#agreement ⇒ Object
13 14 15 |
# File 'lib/comic_walker/client/license.rb', line 13 def agreement @json['agreement'] end |
#get_info ⇒ Object
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_url ⇒ Object
21 22 23 |
# File 'lib/comic_walker/client/license.rb', line 21 def info_url agreement['url_prefix'] + agreement['info_file_name'] end |
#jar_url ⇒ Object
17 18 19 |
# File 'lib/comic_walker/client/license.rb', line 17 def jar_url agreement['url_prefix'] + agreement['jar_file_name'] end |
#key ⇒ Object
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 |