Class: SameSame::Cluster
- Inherits:
-
Object
- Object
- SameSame::Cluster
- Defined in:
- lib/same_same/cluster.rb
Instance Attribute Summary collapse
-
#datapoints ⇒ Object
note to self - unless I need to implement a heap more, i’m just wrapping an array and delegating…
-
#name ⇒ Object
note to self - unless I need to implement a heap more, i’m just wrapping an array and delegating…
Instance Method Summary collapse
- #+(other) ⇒ Object
-
#initialize(dp, name = nil) ⇒ Cluster
constructor
A new instance of Cluster.
- #inject(i, &block) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(dp, name = nil) ⇒ Cluster
Returns a new instance of Cluster.
7 8 9 10 |
# File 'lib/same_same/cluster.rb', line 7 def initialize( dp, name = nil ) self.datapoints = dp self.name = name end |
Instance Attribute Details
#datapoints ⇒ Object
note to self - unless I need to implement a heap more, i’m just wrapping an array and delegating…
5 6 7 |
# File 'lib/same_same/cluster.rb', line 5 def datapoints @datapoints end |
#name ⇒ Object
note to self - unless I need to implement a heap more, i’m just wrapping an array and delegating…
5 6 7 |
# File 'lib/same_same/cluster.rb', line 5 def name @name end |
Instance Method Details
#+(other) ⇒ Object
12 13 14 15 16 |
# File 'lib/same_same/cluster.rb', line 12 def +( other ) names = [name, other.name].compact new_name = names.empty? ? nil : names.join("+") Cluster.new( datapoints + other.datapoints, new_name ) end |
#inject(i, &block) ⇒ Object
22 23 24 |
# File 'lib/same_same/cluster.rb', line 22 def inject(i, &block) datapoints.inject(i, &block) end |
#size ⇒ Object
18 19 20 |
# File 'lib/same_same/cluster.rb', line 18 def size datapoints.size end |