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



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

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

#identicalObject



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

def identical = sites.select { it.types == canonical.types }

#massObject



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

def mass = canonical.mass

#massesObject



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

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

#othersObject



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 }

#sizeObject



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

def size = sites.size

#structural?Boolean

Returns:

  • (Boolean)


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

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