Class: Glaemscribe::API::TranscriptionPrePostProcessor
- Inherits:
-
Object
- Object
- Glaemscribe::API::TranscriptionPrePostProcessor
- Defined in:
- lib/api/transcription_pre_post_processor.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#operators ⇒ Object
readonly
Returns the value of attribute operators.
-
#root_code_block ⇒ Object
readonly
Returns the value of attribute root_code_block.
Instance Method Summary collapse
-
#apply(l) ⇒ Object
Apply all preprocessor rules consecutively.
- #descend_if_tree(code_block, trans_options) ⇒ Object
- #finalize(trans_options) ⇒ Object
-
#initialize(mode) ⇒ TranscriptionPrePostProcessor
constructor
A new instance of TranscriptionPrePostProcessor.
Constructor Details
#initialize(mode) ⇒ TranscriptionPrePostProcessor
Returns a new instance of TranscriptionPrePostProcessor.
59 60 61 62 |
# File 'lib/api/transcription_pre_post_processor.rb', line 59 def initialize(mode) @mode = mode @root_code_block = IfTree::CodeBlock.new end |
Instance Attribute Details
#operators ⇒ Object (readonly)
Returns the value of attribute operators.
57 58 59 |
# File 'lib/api/transcription_pre_post_processor.rb', line 57 def operators @operators end |
#root_code_block ⇒ Object (readonly)
Returns the value of attribute root_code_block.
55 56 57 |
# File 'lib/api/transcription_pre_post_processor.rb', line 55 def root_code_block @root_code_block end |
Instance Method Details
#apply(l) ⇒ Object
Apply all preprocessor rules consecutively
95 96 97 98 99 100 101 |
# File 'lib/api/transcription_pre_post_processor.rb', line 95 def apply(l) ret = l @operators.each{ |operator| ret = operator.apply(ret) } ret end |
#descend_if_tree(code_block, trans_options) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/api/transcription_pre_post_processor.rb', line 64 def descend_if_tree(code_block, ) code_block.terms.each{ |term| if(term.is_pre_post_processor_operators?) term.operators.each{ |operator| @operators << operator } else term.if_conds.each{ |if_cond| if_eval = Eval::Parser.new() if(if_eval.parse(if_cond.expression, ) == true) descend_if_tree(if_cond.child_code_block, ) break end } end } end |
#finalize(trans_options) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/api/transcription_pre_post_processor.rb', line 84 def finalize() @operators = [] # Select operators depending on conditions descend_if_tree(@root_code_block, ) # Reevaluate operator arguments @operators.each{ |op| op.finalize() } end |