Class: ExclusiveOrExpression

Inherits:
OrExpression show all
Defined in:
lib/glark/match/xor.rb

Overview

Evaluates the expressions, and is satisfied if only one returns true.

Instance Attribute Summary

Attributes inherited from CompoundExpression

#ops

Attributes inherited from Expression

#matches

Instance Method Summary collapse

Methods inherited from OrExpression

#end_position, #evaluate, #explain, #inspect

Methods inherited from CompoundExpression

#==, #initialize, #reset_file, #start_position

Methods inherited from Expression

#add_match, #end_position, #initialize, #process, #reset_file, #start_position, #to_s

Constructor Details

This class inherits a constructor from CompoundExpression

Instance Method Details

#criteriaObject



17
18
19
# File 'lib/glark/match/xor.rb', line 17

def criteria
  "only one of"
end

#is_match?(matched_ops) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/glark/match/xor.rb', line 9

def is_match? matched_ops
  return matched_ops.size == 1
end

#operatorObject



13
14
15
# File 'lib/glark/match/xor.rb', line 13

def operator
  "xor"
end