Class: ConcatOperator
- Inherits:
-
RegexOperator
- Object
- RegexOperator
- ConcatOperator
- Defined in:
- lib/ruby_grammar_builder/regex_operators/concat.rb
Overview
The standard RegexOperator, provides concatination
Instance Attribute Summary
Attributes inherited from RegexOperator
Instance Method Summary collapse
-
#do_evaluate_self(arr_left, arr_right) ⇒ Array<RegexOperator,String>
abstract
<Description>.
-
#initialize ⇒ ConcatOperator
constructor
A new instance of ConcatOperator.
Methods inherited from RegexOperator
#==, evaluate, #fold_left, #fold_right
Constructor Details
#initialize ⇒ ConcatOperator
Returns a new instance of ConcatOperator.
9 10 11 12 |
# File 'lib/ruby_grammar_builder/regex_operators/concat.rb', line 9 def initialize @precedence = 2 @association = :left end |
Instance Method Details
#do_evaluate_self(arr_left, arr_right) ⇒ Array<RegexOperator,String>
This method is abstract.
override to provide evaluate the operator
Note:
arr_left and arr_right contain the entire parse array use RegexOperator#fold_left and RegexOperator#fold_right to collect only the portions that this operator is responsible for
<Description>
15 16 17 18 19 20 21 22 |
# File 'lib/ruby_grammar_builder/regex_operators/concat.rb', line 15 def do_evaluate_self(arr_left, arr_right) left = fold_left(arr_left) right = fold_right(arr_right) self_string = left[0]+right[0] [left[1], self_string, right[1]].flatten end |