Class: MetadataPresenter::Operator
- Inherits:
-
Object
- Object
- MetadataPresenter::Operator
- Defined in:
- app/operators/metadata_presenter/operator.rb
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Instance Method Summary collapse
- #evaluate(actual, expected) ⇒ Object
-
#initialize(operator) ⇒ Operator
constructor
A new instance of Operator.
- #klass ⇒ Object
Constructor Details
#initialize(operator) ⇒ Operator
Returns a new instance of Operator.
8 9 10 |
# File 'app/operators/metadata_presenter/operator.rb', line 8 def initialize(operator) @operator = operator end |
Instance Attribute Details
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
6 7 8 |
# File 'app/operators/metadata_presenter/operator.rb', line 6 def operator @operator end |
Instance Method Details
#evaluate(actual, expected) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/operators/metadata_presenter/operator.rb', line 12 def evaluate(actual, expected) operator = klass.constantize.new(actual, expected) if expected.is_a?(Array) operator.evaluate_collection? else operator.evaluate? end rescue NameError raise NoOperator, "Operator '#{operator}' is not implemented. You need to create the class #{klass}" end |
#klass ⇒ Object
25 26 27 |
# File 'app/operators/metadata_presenter/operator.rb', line 25 def klass "MetadataPresenter::#{@operator.capitalize.classify}Operator" end |