Sha256: 93764bd1e752eeffc1881fb3e15f1e09d01164846c51888087973c450afedd7c
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true module Apkstats::Entity class Permission # String attr_reader :name # String? attr_reader :max_sdk def initialize(name, max_sdk: nil) @name = name @max_sdk = max_sdk end def to_s if max_sdk "#{name} maxSdkVersion=#{max_sdk}" else name end end def ==(other) return if !other || other.class != self.class to_s == other.to_s end def eql?(other) to_s.eql?(other.to_s) end def hash h = name.hash if max_sdk h *= 31 h += max_sdk.hash end h end end class Permissions attr_reader :values # Array<Permission> def initialize(permission_arr) @values = permission_arr end def -(other) raise "#{self.class} cannot handle #{other.class} with the minus operator" unless other.class == Permissions self_hash = Permissions.hashnize(self) other_hash = Permissions.hashnize(other) diff_permissions = (self_hash.keys - other_hash.keys).map do |key| self_hash[key] end Permissions.new(diff_permissions) end def to_a values.map(&:to_s) end def eql?(other) return if !other || other.class == Permissions other.values == values end def hash values.hash end def self.hashnize(permissions) permissions.values.each_with_object({}) do |permission, acc| acc[[permission.name, permission.max_sdk]] = permission end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
danger-apkstats-0.3.1 | lib/apkstats/entity/permission.rb |
danger-apkstats-0.3.0 | lib/apkstats/entity/permission.rb |