class FlexStationData::ValueQuality

Attributes

threshold[R]
value[R]

Public Class Methods

new(value, threshold: nil, **_options) click to toggle source
# File lib/flex_station_data/services/value_quality.rb, line 42
def initialize(value, threshold: nil, **_options)
  @value = value
  @threshold = threshold
end

Public Instance Methods

below_threshold?() click to toggle source
# File lib/flex_station_data/services/value_quality.rb, line 59
def below_threshold?
  threshold.present? && value.is_a?(Numeric) && value < threshold
end
call() click to toggle source
# File lib/flex_station_data/services/value_quality.rb, line 63
def call
  if no_data?
    Bad.new("No data")
  elsif saturated?
    Bad.new("Saturated")
  elsif invalid?
    Bad.new("Invalid data")
  elsif below_threshold?
    Bad.new("Below threshold")
  else
    Good.instance
  end
end
invalid?() click to toggle source
# File lib/flex_station_data/services/value_quality.rb, line 55
def invalid?
  !(no_data? || saturated? || value.is_a?(Numeric))
end
no_data?() click to toggle source
# File lib/flex_station_data/services/value_quality.rb, line 47
def no_data?
  value.blank?
end
saturated?() click to toggle source
# File lib/flex_station_data/services/value_quality.rb, line 51
def saturated?
  value == "#SAT"
end