Class: Hashira::Duplication::Cluster

Inherits:
Data
  • Object
show all
Defined in:
lib/hashira/duplication/cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sitesObject (readonly)

Returns the value of attribute sites

Returns:

  • (Object)

    the current value of sites



5
6
7
# File 'lib/hashira/duplication/cluster.rb', line 5

def sites
  @sites
end

Instance Method Details

#canonicalObject



6
# File 'lib/hashira/duplication/cluster.rb', line 6

def canonical = sites.max_by { |site| [shape_count(site), site.mass] }

#massObject



15
# File 'lib/hashira/duplication/cluster.rb', line 15

def mass = canonical.mass

#othersObject



10
11
12
13
# File 'lib/hashira/duplication/cluster.rb', line 10

def others
  chosen = canonical
  sites.reject { |site| site.equal?(chosen) }
end

#shape_count(site) ⇒ Object



8
# File 'lib/hashira/duplication/cluster.rb', line 8

def shape_count(site) = sites.count { |other| other.types == site.types }

#shape_only?Boolean

Returns:

  • (Boolean)


21
# File 'lib/hashira/duplication/cluster.rb', line 21

def shape_only? = others.all? { Variance.new(canonical, it).shape_only? }

#site_massesObject



19
# File 'lib/hashira/duplication/cluster.rb', line 19

def site_masses = sites.map { [it.file, mass] }

#sizeObject



17
# File 'lib/hashira/duplication/cluster.rb', line 17

def size = sites.size