Module: ParamsReady::Value::OperatorConstraint::ClampingCondition

Included in:
Condition
Defined in:
lib/params_ready/value/constraint.rb

Constant Summary collapse

CLAMPING_OPERATORS =
%i(<= == >=).to_set.freeze

Instance Method Summary collapse

Instance Method Details

#clamp(_) ⇒ Object



145
146
147
148
149
150
151
152
# File 'lib/params_ready/value/constraint.rb', line 145

def clamp(_)
  case @operator
  when :<=, :>=, :==
    get_value
  else
    raise "Unexpected operator: #{@operator}"
  end
end

#clamp?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/params_ready/value/constraint.rb', line 154

def clamp?
  CLAMPING_OPERATORS.member? @operator
end