Sha256: 505de842b3e6d408ba0e4a142e94fe2619bf85878270875850875110b08b1e62
Contents?: true
Size: 640 Bytes
Versions: 4
Compression:
Stored size: 640 Bytes
Contents
# frozen_string_literal: true require "cgi" module Miteru class Kit VALID_EXTENSIONS = [".zip", ".rar", ".7z", ".tar", ".gz"].freeze attr_reader :base_url, :link def initialize(base_url:, link:) @base_url = base_url @link = link.start_with?("/") ? link[1..-1] : link end def valid? VALID_EXTENSIONS.include? extname end def extname return ".tar.gz" if link.end_with?("tar.gz") File.extname(link) end def basename File.basename(link) end def filename CGI.unescape basename end def url "#{base_url}/#{basename}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
miteru-0.12.12 | lib/miteru/kit.rb |
miteru-0.12.11 | lib/miteru/kit.rb |
miteru-0.12.10 | lib/miteru/kit.rb |
miteru-0.12.9 | lib/miteru/kit.rb |