Class: Apkstats::Entity::Permissions

Inherits:
Object
  • Object
show all
Defined in:
lib/apkstats/entity/permission.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(permission_arr) ⇒ Permissions

Array<Permission>



50
51
52
# File 'lib/apkstats/entity/permission.rb', line 50

def initialize(permission_arr)
  @values = permission_arr
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



47
48
49
# File 'lib/apkstats/entity/permission.rb', line 47

def values
  @values
end

Class Method Details

.hashnize(permissions) ⇒ Object



80
81
82
83
84
# File 'lib/apkstats/entity/permission.rb', line 80

def self.hashnize(permissions)
  permissions.values.each_with_object({}) do |permission, acc|
    acc[[permission.name, permission.max_sdk]] = permission
  end
end

Instance Method Details

#-(other) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# 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) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
# File 'lib/apkstats/entity/permission.rb', line 71

def eql?(other)
  return if !other || other.class == Permissions
  other.values == values
end

#hashObject



76
77
78
# File 'lib/apkstats/entity/permission.rb', line 76

def hash
  values.hash
end

#to_aObject



67
68
69
# File 'lib/apkstats/entity/permission.rb', line 67

def to_a
  values.map(&:to_s)
end