Class: Apkstats::Entity::Feature
- Inherits:
-
Object
- Object
- Apkstats::Entity::Feature
- Defined in:
- lib/apkstats/entity/feature.rb
Instance Attribute Summary collapse
-
#implied_reason ⇒ Object
readonly
String?.
-
#name ⇒ Object
readonly
String.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #implied? ⇒ Boolean
-
#initialize(name, not_required: false, implied_reason: nil) ⇒ Feature
constructor
A new instance of Feature.
- #not_required? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(name, not_required: false, implied_reason: nil) ⇒ Feature
Returns a new instance of Feature.
11 12 13 14 15 16 |
# File 'lib/apkstats/entity/feature.rb', line 11 def initialize(name, not_required: false, implied_reason: nil) @name = name # cast to Boolean @not_required = not_required == true @implied_reason = implied_reason || nil end |
Instance Attribute Details
#implied_reason ⇒ Object (readonly)
String?
9 10 11 |
# File 'lib/apkstats/entity/feature.rb', line 9 def implied_reason @implied_reason end |
#name ⇒ Object (readonly)
String
6 7 8 |
# File 'lib/apkstats/entity/feature.rb', line 6 def name @name end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 39 40 |
# File 'lib/apkstats/entity/feature.rb', line 36 def ==(other) return if !other || other.class != self.class to_s == other.to_s end |
#eql?(other) ⇒ Boolean
42 43 44 |
# File 'lib/apkstats/entity/feature.rb', line 42 def eql?(other) to_s.eql?(other.to_s) end |
#hash ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/apkstats/entity/feature.rb', line 46 def hash h = not_required? ? 1 : 0 h *= 31 h += name.hash if implied_reason h *= 31 h += implied_reason.hash end h end |
#implied? ⇒ Boolean
22 23 24 |
# File 'lib/apkstats/entity/feature.rb', line 22 def implied? @implied_reason end |
#not_required? ⇒ Boolean
18 19 20 |
# File 'lib/apkstats/entity/feature.rb', line 18 def not_required? @not_required end |
#to_s ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/apkstats/entity/feature.rb', line 26 def to_s if implied? "#{name} (#{implied_reason})" elsif not_required? "#{name} (not-required)" else name end end |