Top Level Namespace

Defined Under Namespace

Modules: Goling Classes: Ruby2Js, String

Instance Method Summary collapse

Instance Method Details

#reduce(regexp, &code) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/goling.rb', line 6

def reduce(regexp,&code)
  Goling::rules << {
    :match  => regexp.keys[0],
    :result => regexp.values[0].kind_of?(Hash)                                     ? regexp.values[0][:to]     : regexp.values[0],
    :lang   => regexp.values[0].kind_of?(Hash)                                     ? regexp.values[0][:lang]   : :ruby, 
    :inline => regexp.values[0].kind_of?(Hash)&&regexp.values[0].has_key?(:inline) ? regexp.values[0][:inline] : false,
    :proc => code
  }
end