Sha256: 6a56748095600ecd74ef4c3d0b829a3f075623163d87c562bba1d6a5a8167fc6

Contents?: true

Size: 1.2 KB

Versions: 11

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

# AppInfo base file
module AppInfo
  class File
    attr_reader :file, :logger

    def initialize(file, logger: AppInfo.logger)
      @file = file
      @logger = logger
    end

    # @return [Symbol] {Format}
    def format
      @format ||= lambda {
        if instance_of?(AppInfo::File) || instance_of?(AppInfo::Apple) ||
           instance_of?(AppInfo::Android)
          not_implemented_error!(__method__)
        end

        self.class.name.split('::')[-1].downcase.to_sym
      }.call
    end

    # @abstract Subclass and override {#platform} to implement.
    def platform
      not_implemented_error!(__method__)
    end

    # @abstract Subclass and override {#manufacturer} to implement.
    def manufacturer
      not_implemented_error!(__method__)
    end

    # @abstract Subclass and override {#device} to implement.
    def device
      not_implemented_error!(__method__)
    end

    # @abstract Subclass and override {#size} to implement
    def size(human_size: false)
      not_implemented_error!(__method__)
    end

    def not_implemented_error!(method)
      raise NotImplementedError, ".#{method} method implantation required in #{self.class}"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
app-info-3.3.0 lib/app_info/file.rb
app-info-3.2.0 lib/app_info/file.rb
app-info-3.2.0.beta1 lib/app_info/file.rb
app-info-3.1.4 lib/app_info/file.rb
app-info-3.1.3 lib/app_info/file.rb
app-info-3.1.2 lib/app_info/file.rb
app-info-3.1.1 lib/app_info/file.rb
app-info-3.1.0 lib/app_info/file.rb
app-info-3.0.0 lib/app_info/file.rb
app-info-3.0.0.beta4 lib/app_info/file.rb
app-info-3.0.0.beta3 lib/app_info/file.rb