Class: ParamsReady::Value::OperatorConstraint::Condition

Inherits:
Object
  • Object
show all
Includes:
ClampingCondition
Defined in:
lib/params_ready/value/constraint.rb

Direct Known Subclasses

DynamicCondition, StaticCondition

Constant Summary

Constants included from ClampingCondition

ParamsReady::Value::OperatorConstraint::ClampingCondition::CLAMPING_OPERATORS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClampingCondition

#clamp, #clamp?

Constructor Details

#initialize(operator, value) ⇒ Condition

Returns a new instance of Condition.



162
163
164
165
# File 'lib/params_ready/value/constraint.rb', line 162

def initialize(operator, value)
  @operator = operator
  @value = value
end

Class Method Details

.instance(operator, value) ⇒ Object



175
176
177
178
179
180
181
182
# File 'lib/params_ready/value/constraint.rb', line 175

def self.instance(operator, value)
  case value
  when Method, Proc
     DynamicCondition.new operator, value
  else
     StaticCondition.new operator, value
  end
end

Instance Method Details

#error_messageObject



171
172
173
# File 'lib/params_ready/value/constraint.rb', line 171

def error_message
  "not #{@operator} #{get_value}"
end

#true?(input) ⇒ Boolean

Returns:

  • (Boolean)


167
168
169
# File 'lib/params_ready/value/constraint.rb', line 167

def true?(input)
  input.send(@operator, get_value)
end