Sha256: f4c403c52bb6cf57c3d3cdba434ece4787ce858a315acdafb4f3ecc5a3393502

Contents?: true

Size: 519 Bytes

Versions: 3

Compression:

Stored size: 519 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
      File.extname(link)
    end

    def basename
      File.basename(link)
    end

    def url
      "#{base_url}/#{basename}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
miteru-0.12.3 lib/miteru/kit.rb
miteru-0.12.2 lib/miteru/kit.rb
miteru-0.12.1 lib/miteru/kit.rb