Top Level Namespace
Defined Under Namespace
Modules: Linguify Classes: Proc, Ruby2Js, Sexp, String
Instance Method Summary collapse
-
#reduce(regexp, &code) ⇒ Object
Defines a reduction rule.
Instance Method Details
#reduce(regexp, &code) ⇒ Object
Defines a reduction rule.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/linguify.rb', line 55 def reduce(regexp,&code) rule = if regexp.kind_of? Regexp { :match => regexp, :result => '', :lang => :ruby, :inline => false, :proc => code } elsif regexp.values[0].kind_of?(Hash) { :match => regexp.keys[0], :result => regexp.values[0][:to] || '', :lang => regexp.values[0][:lang] || :ruby, :inline => regexp.values[0][:inline] || false, :proc => code } else { :match => regexp.keys[0], :result => regexp.values[0], :lang => :ruby, :inline => false, :proc => code } end Linguify::rules << rule end |