Class: ParamsReady::Value::OperatorConstraint::Condition
- Inherits:
-
Object
- Object
- ParamsReady::Value::OperatorConstraint::Condition
show all
- Includes:
- ClampingCondition
- Defined in:
- lib/params_ready/value/constraint.rb
Constant Summary
ParamsReady::Value::OperatorConstraint::ClampingCondition::CLAMPING_OPERATORS
Class Method Summary
collapse
Instance Method Summary
collapse
#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_message ⇒ Object
171
172
173
|
# File 'lib/params_ready/value/constraint.rb', line 171
def error_message
"not #{@operator} #{get_value}"
end
|
#true?(input) ⇒ Boolean
167
168
169
|
# File 'lib/params_ready/value/constraint.rb', line 167
def true?(input)
input.send(@operator, get_value)
end
|