Class: Glaemscribe::API::TranscriptionPrePostProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/api/transcription_pre_post_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode) ⇒ TranscriptionPrePostProcessor

Returns a new instance of TranscriptionPrePostProcessor.



65
66
67
68
# File 'lib/api/transcription_pre_post_processor.rb', line 65

def initialize(mode)
  @mode             = mode
  @root_code_block  = IfTree::CodeBlock.new 
end

Instance Attribute Details

#operatorsObject (readonly)

Returns the value of attribute operators.



63
64
65
# File 'lib/api/transcription_pre_post_processor.rb', line 63

def operators
  @operators
end

#root_code_blockObject (readonly)

Returns the value of attribute root_code_block.



61
62
63
# File 'lib/api/transcription_pre_post_processor.rb', line 61

def root_code_block
  @root_code_block
end

Instance Method Details

#descend_if_tree(code_block, trans_options) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/api/transcription_pre_post_processor.rb', line 70

def descend_if_tree(code_block, trans_options)
  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, trans_options) == true)
          descend_if_tree(if_cond.child_code_block, trans_options)
          break
        end
      }
    end
  }
end

#finalize(trans_options) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/api/transcription_pre_post_processor.rb', line 90

def finalize(trans_options)
  @operators = []
  # Select operators depending on conditions
  descend_if_tree(@root_code_block, trans_options)
  # Reevaluate operator arguments
  @operators.each{ |op|
    op.finalize(trans_options)
  }
end