class Apkstats::Entity::Permissions

Attributes

values[R]

Public Class Methods

hashnize(permissions) click to toggle source
# File lib/apkstats/entity/permission.rb, line 81
def self.hashnize(permissions)
  permissions.values.each_with_object({}) do |permission, acc|
    acc[[permission.name, permission.max_sdk]] = permission
  end
end
new(permission_arr) click to toggle source

Array<Permission>

# File lib/apkstats/entity/permission.rb, line 50
def initialize(permission_arr)
  @values = permission_arr
end

Public Instance Methods

-(other) click to toggle source
# File lib/apkstats/entity/permission.rb, line 54
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
eql?(other) click to toggle source
# File lib/apkstats/entity/permission.rb, line 71
def eql?(other)
  return if !other || other.class == Permissions

  other.values == values
end
hash() click to toggle source
# File lib/apkstats/entity/permission.rb, line 77
def hash
  values.hash
end
to_a() click to toggle source
# File lib/apkstats/entity/permission.rb, line 67
def to_a
  values.map(&:to_s)
end