Sha256: 646e204651622e8a3a289f5b2928c7f7a55f615e0ead22824f30d0b520c226fa

Contents?: true

Size: 571 Bytes

Versions: 5

Compression:

Stored size: 571 Bytes

Contents

# frozen_string_literal: true

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 url
      "#{base_url}/#{basename}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
miteru-0.12.8 lib/miteru/kit.rb
miteru-0.12.7 lib/miteru/kit.rb
miteru-0.12.6 lib/miteru/kit.rb
miteru-0.12.5 lib/miteru/kit.rb
miteru-0.12.4 lib/miteru/kit.rb