Class: Glaemscribe::API::ElvishNumbersPreProcessorOperator

Inherits:
PreProcessorOperator show all
Defined in:
lib/api/pre_processor/elvish_numbers.rb

Instance Attribute Summary

Attributes inherited from PrePostProcessorOperator

#finalized_glaeml_element, #glaeml_element

Instance Method Summary collapse

Methods inherited from PrePostProcessorOperator

#eval_arg, #finalize, #finalize_glaeml_element, #initialize

Constructor Details

This class inherits a constructor from Glaemscribe::API::PrePostProcessorOperator

Instance Method Details

#apply(l) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/api/pre_processor/elvish_numbers.rb', line 28

def apply(l)
  base    = finalized_glaeml_element.args[0]
  base    = (base)?(base.to_i):(12)
  
  reverse = finalized_glaeml_element.args[1]
  reverse = (reverse != nil)?(reverse == "true" || reverse == true):(true) 

  l.gsub(/\d+/) { |f| 
    ret = f.to_i.to_s(base).upcase()
    ret = ret.reverse if(reverse) 
    ret        
  }
end