Sha256: b69f8529b2689804888415d9eaa1a4b87423449681ae04552efb0423db2e881b

Contents?: true

Size: 784 Bytes

Versions: 11

Compression:

Stored size: 784 Bytes

Contents

require 'link_thumbnailer/model'
require 'link_thumbnailer/grader'

module LinkThumbnailer
  module Models
    class Description < ::LinkThumbnailer::Model

      attr_reader   :node, :text, :position, :candidates_number
      attr_accessor :probability

      def initialize(node, text, position = 1, candidates_number = 1)
        @node              = node
        @text              = sanitize(text)
        @position          = position
        @candidates_number = candidates_number
        @probability       = compute_probability
      end

      def to_s
        text
      end

      def <=>(other)
        probability <=> other.probability
      end

      private

      def compute_probability
        ::LinkThumbnailer::Grader.new(self).call
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
link_thumbnailer-3.3.1 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.3.0 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.2.1 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.2.0 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.1.2 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.1.1 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.1.0 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.0.3 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.0.2 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.0.1 lib/link_thumbnailer/models/description.rb
link_thumbnailer-3.0.0 lib/link_thumbnailer/models/description.rb