Class: Hashira::Duplication::Cluster
- Inherits:
-
Data
- Object
- Data
- Hashira::Duplication::Cluster
- Defined in:
- lib/hashira/duplication/cluster.rb
Instance Attribute Summary collapse
-
#sites ⇒ Object
readonly
Returns the value of attribute sites.
Instance Method Summary collapse
- #canonical ⇒ Object
- #identical ⇒ Object
- #mass ⇒ Object
- #masses ⇒ Object
- #others ⇒ Object
- #shapes(site) ⇒ Object
- #size ⇒ Object
- #structural? ⇒ Boolean
Instance Attribute Details
#sites ⇒ Object (readonly)
Returns the value of attribute sites
5 6 7 |
# File 'lib/hashira/duplication/cluster.rb', line 5 def sites @sites end |
Instance Method Details
#canonical ⇒ Object
7 |
# File 'lib/hashira/duplication/cluster.rb', line 7 def canonical = sites.max_by { |site| [shapes(site), site.mass] } |
#identical ⇒ Object
16 |
# File 'lib/hashira/duplication/cluster.rb', line 16 def identical = sites.select { it.types == canonical.types } |
#mass ⇒ Object
18 |
# File 'lib/hashira/duplication/cluster.rb', line 18 def mass = canonical.mass |
#masses ⇒ Object
22 |
# File 'lib/hashira/duplication/cluster.rb', line 22 def masses = sites.map { [it.file, mass] } |
#others ⇒ Object
11 12 13 14 |
# File 'lib/hashira/duplication/cluster.rb', line 11 def others chosen = canonical sites.reject { |site| site.equal?(chosen) } end |
#shapes(site) ⇒ Object
9 |
# File 'lib/hashira/duplication/cluster.rb', line 9 def shapes(site) = sites.count { |other| other.types == site.types } |
#size ⇒ Object
20 |
# File 'lib/hashira/duplication/cluster.rb', line 20 def size = sites.size |
#structural? ⇒ Boolean
24 |
# File 'lib/hashira/duplication/cluster.rb', line 24 def structural? = others.all? { Variance.new(canonical, it).structural? } |