Sha256: 56cf4659f10769f6e3b684c2aa48c4ac362982e9706465605df0e0772a51b350

Contents?: true

Size: 925 Bytes

Versions: 6

Compression:

Stored size: 925 Bytes

Contents

module DbClustering
  module Models
    class Point

      attr_accessor :cluster, :is_noise, :datasource_point

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

      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

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

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

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

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

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
db_clustering-0.1.6 lib/models/point.rb
db_clustering-0.1.5 lib/models/point.rb
db_clustering-0.1.4 lib/models/point.rb
db_clustering-0.1.3 lib/models/point.rb
db_clustering-0.1.2 lib/models/point.rb
db_clustering-0.1.1 lib/models/point.rb