Sha256: 509548ccac21b18683cc3a8e98901d78643eb3113aa87fa50cfa3d3f6bb94bb2
Contents?: true
Size: 1.01 KB
Versions: 53
Compression:
Stored size: 1.01 KB
Contents
module Ruby2JS class Converter # (regexp # (str "x") # (regopt :i)) handle :regexp do |*parts, opt| extended = false opts = opt.children if opts.include? :x opts = opts.dup - [:x] extended = true end if parts.all? {|part| part.type == :str} str = parts.map {|part| part.children.first}.join str = str.gsub(/ #.*/,'').gsub(/\s/,'') if extended unless str.include? '/' return put "/#{ str }/#{ opts.join }" end put "new RegExp(#{ str.inspect }" else put 'new RegExp(' parts.each_with_index do |part, index| put ' + ' unless index == 0 if part.type == :str str = part.children.first str = str.gsub(/ #.*/,'').gsub(/\s/,'') if extended put str.inspect else parse part end end end unless opts.empty? put ", #{ opts.join.inspect}" end put ')' end end end
Version data entries
53 entries across 53 versions & 1 rubygems