Sha256: 6c5bc068412aa628576760afec3a6f984bdb3119872b47d05ea5b118eb9cdd55

Contents?: true

Size: 430 Bytes

Versions: 6

Compression:

Stored size: 430 Bytes

Contents

module Ruby2JS
  class Converter

    # (regexp
    #   (str "x")
    #   (regopt :i))

    handle :regexp do |str, opt|
      str = str.children.first 
      if str.include? '/'
        if opt.children.empty?
          "new RegExp(#{ str.inspect })"
        else
          "new RegExp(#{ str.inspect }, #{ opt.children.join.inspect})"
        end
      else
        "/#{ str }/#{ opt.children.join }"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby2js-1.1.5 lib/ruby2js/converter/regexp.rb
ruby2js-1.1.4 lib/ruby2js/converter/regexp.rb
ruby2js-1.1.3 lib/ruby2js/converter/regexp.rb
ruby2js-1.1.2 lib/ruby2js/converter/regexp.rb
ruby2js-1.1.1 lib/ruby2js/converter/regexp.rb
ruby2js-1.1.0 lib/ruby2js/converter/regexp.rb