examples/general/SRL/lib/regex/alternation.rb in rley-0.6.00 vs examples/general/SRL/lib/regex/alternation.rb in rley-0.6.01
- old
+ new
@@ -1,31 +1,27 @@
# File: alternation.rb
-require_relative 'polyadic_expression' # Access the superclass
+require_relative 'polyadic_expression' # Access the superclass
module Regex # This module is used as a namespace
+ # Abstract class. A n-ary matching operator.
+ # It succeeds when one child expression succeeds to match the subject text
+ class Alternation < PolyadicExpression
+ # Constructor.
+ def initialize(*theChildren)
+ super(theChildren)
+ end
-# Abstract class. A n-ary matching operator.
-# It succeeds when one child expression succeeds to match the subject text
-class Alternation < PolyadicExpression
-
- # Constructor.
- def initialize(*theChildren)
- super(theChildren)
- end
+ protected
- protected
+ # Conversion method re-definition.
+ # Purpose: Return the String representation of the concatented expressions.
+ def text_repr()
+ result_children = children.map(&:to_str)
+ result = '(?:' + result_children.join('|') + ')'
- # Conversion method re-definition.
- # Purpose: Return the String representation of the concatented expressions.
- def text_repr()
- result_children = children.map { |aChild| aChild.to_str() }
- result = '(?:' + result_children.join('|') + ')'
-
- return result
- end
-
-end # class
-
+ return result
+ end
+ end # class
end # module
-# End of file
\ No newline at end of file
+# End of file