class DotDiff::ThresholdCalculator
Constants
- PERCENT
- PIXEL
Attributes
pixel_diff[R]
threshold_config[R]
total_pixels[R]
value[R]
Public Class Methods
new(threshold_config, total_pixels, pixel_diff)
click to toggle source
# File lib/dotdiff/threshold_calculator.rb, line 8 def initialize(threshold_config, total_pixels, pixel_diff) @threshold_config = threshold_config @total_pixels = total_pixels @pixel_diff = pixel_diff end
Public Instance Methods
message()
click to toggle source
# File lib/dotdiff/threshold_calculator.rb, line 29 def message "Outcome was '#{value}' difference for type '#{threshold_type}'" end
under_threshold?()
click to toggle source
# File lib/dotdiff/threshold_calculator.rb, line 14 def under_threshold? return false if total_pixels.nil? || pixel_diff.nil? case threshold_type when PIXEL @value = pixel_diff when PERCENT @value = pixel_diff / total_pixels.to_f else raise UnknownTypeError, "Unable to handle threshold type: #{threshold_type}" end value <= threshold_value end
Private Instance Methods
threshold_type()
click to toggle source
# File lib/dotdiff/threshold_calculator.rb, line 43 def threshold_type return PIXEL if threshold_config.class != Hash threshold_config[:type].to_s end
threshold_value()
click to toggle source
# File lib/dotdiff/threshold_calculator.rb, line 37 def threshold_value return threshold_config if threshold_config.class == Integer threshold_config[:value] end