Sha256: 941cbdd2b749b8e053f88b452a3770c8a80a7152a6d70adbaca39f0c622e0ad6

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Apkstats::Entity
  class ApkInfoDiff
    KEYS = Apkstats::Entity::ApkInfo::KEYS

    # ApkInfo
    attr_reader :base, :other

    private(:base, :other)

    def initialize(base, other)
      @base = base
      @other = other
    end

    def to_h
      KEYS.each_with_object({}) do |key, acc|
        acc[key] = self.send(key)
      end.compact
    end

    def file_size
      # Integer
      @base[__method__].to_i - @other[__method__].to_i
    end

    def download_size
      # Integer
      @base[__method__].to_i - @other[__method__].to_i
    end

    def required_features
      # Features
      {
          new: (@base[__method__] - @other[__method__]).to_a,
          removed: (@other[__method__] - @base[__method__]).to_a,
      }
    end

    def non_required_features
      # Features
      {
          new: (@base[__method__] - @other[__method__]).to_a,
          removed: (@other[__method__] - @base[__method__]).to_a,
      }
    end

    def permissions
      # Permissions
      {
          new: (@base[__method__] - @other[__method__]).to_a,
          removed: (@other[__method__] - @base[__method__]).to_a,
      }
    end

    def min_sdk
      # String
      [@base[__method__], @other[__method__]].uniq
    end

    def target_sdk
      # String
      [@base[__method__], @other[__method__]].uniq
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danger-apkstats-0.1.2 lib/apkstats/entity/apk_info_diff.rb
danger-apkstats-0.1.1.pre.1 lib/apkstats/entity/apk_info_diff.rb
danger-apkstats-0.1.0 lib/apkstats/entity/apk_info_diff.rb