Class: Apkstats::Entity::Features

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature_arr) ⇒ Features

Array<Feature>



64
65
66
# File 'lib/apkstats/entity/feature.rb', line 64

def initialize(feature_arr)
  @values = feature_arr
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



61
62
63
# File 'lib/apkstats/entity/feature.rb', line 61

def values
  @values
end

Class Method Details

.hashnize(features) ⇒ Object



95
96
97
98
99
# File 'lib/apkstats/entity/feature.rb', line 95

def self.hashnize(features)
  features.values.each_with_object({}) do |feature, acc|
    acc[[feature.name, feature.not_required?]] = feature
  end
end

Instance Method Details

#-(other) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/apkstats/entity/feature.rb', line 68

def -(other)
  raise "#{self.class} cannot handle #{other.class} with the minus operator" unless other.class == Features

  self_hash = Features.hashnize(self)
  other_hash = Features.hashnize(other)

  diff_features = (self_hash.keys - other_hash.keys).map do |key|
    self_hash[key]
  end

  Features.new(diff_features)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
88
89
# File 'lib/apkstats/entity/feature.rb', line 85

def eql?(other)
  return if !other || other.class == Features

  other.values == values
end

#hashObject



91
92
93
# File 'lib/apkstats/entity/feature.rb', line 91

def hash
  values.hash
end

#to_aObject



81
82
83
# File 'lib/apkstats/entity/feature.rb', line 81

def to_a
  values.map(&:to_s)
end