Class: DbClustering::Models::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/models/point.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datasource_point) ⇒ Point

Returns a new instance of Point.



7
8
9
10
11
# File 'lib/models/point.rb', line 7

def initialize(datasource_point)
  @is_noise = false
  @cluster = nil
  @datasource_point = datasource_point
end

Instance Attribute Details

#clusterObject

Returns the value of attribute cluster.



5
6
7
# File 'lib/models/point.rb', line 5

def cluster
  @cluster
end

#datasource_pointObject

Returns the value of attribute datasource_point.



5
6
7
# File 'lib/models/point.rb', line 5

def datasource_point
  @datasource_point
end

#is_noiseObject

Returns the value of attribute is_noise.



5
6
7
# File 'lib/models/point.rb', line 5

def is_noise
  @is_noise
end

Instance Method Details

#is_core_point?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/models/point.rb', line 31

def is_core_point?
  !self.is_noise && !self.cluster.nil?
end

#is_edge_point?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/models/point.rb', line 27

def is_edge_point?
  self.is_noise && !self.cluster.nil?
end

#is_noise_point?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/models/point.rb', line 35

def is_noise_point?
  self.is_noise && self.cluster.nil?
end

#vectorObject



13
14
15
16
17
18
19
20
21
# File 'lib/models/point.rb', line 13

def vector
  vector_object = @datasource_point.clustering_vector

  if vector_object.is_a?(Hash) || vector_object.is_a?(Array)
    DbClustering::Models::Vector.new(object: vector_object)
  else
    raise "clustering_vector method needs to result to a Hash or an Array object"
  end
end

#visited?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/models/point.rb', line 23

def visited?
  self.is_noise || !self.cluster.nil?
end