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.



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

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

Instance Attribute Details

#operatorsObject (readonly)

Returns the value of attribute operators.



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

def operators
  @operators
end

#root_code_blockObject (readonly)

Returns the value of attribute root_code_block.



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

def root_code_block
  @root_code_block
end

Instance Method Details

#descend_if_tree(code_block, trans_options) ⇒ Object



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

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



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

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