Sha256: 9b81bb2c902fd44edfe6c0af85e0474f41f37531b39077e247fc710c12bca235
Contents?: true
Size: 497 Bytes
Versions: 8
Compression:
Stored size: 497 Bytes
Contents
module LinkThumbnailer module Graders class LinkDensity < ::LinkThumbnailer::Graders::Base def call(current_score) return 0 if density_ratio == 0 current_score *= density_ratio end private def density return 0 if text.length == 0 links.length / text.length.to_f end def density_ratio 1 - density end def links node.css('a').map(&:text).compact.reject(&:empty?) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems