Class: Fastcluster::Cluster

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/fastcluster/cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, size) ⇒ Cluster

Returns a new instance of Cluster.



7
8
9
10
11
# File 'lib/fastcluster/cluster.rb', line 7

def initialize(x, y, size)
  @x = x
  @y = y
  @size = size
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



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

def size
  @size
end

#xObject (readonly)

Returns the value of attribute x.



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

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



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

def y
  @y
end

Instance Method Details

#<=>(anOther) ⇒ Object



13
14
15
# File 'lib/fastcluster/cluster.rb', line 13

def <=>(anOther)
  size <=> anOther.size
end

#inspectObject



17
18
19
# File 'lib/fastcluster/cluster.rb', line 17

def inspect
  to_s
end

#to_sObject



21
22
23
# File 'lib/fastcluster/cluster.rb', line 21

def to_s
  '(%0.2f, %0.2f): %d' % [@x, @y, @size]
end