Sha256: 166c82a88093409898e5029e60b78b5a3e584ad84118e58e15b2effa10f3161a

Contents?: true

Size: 621 Bytes

Versions: 16

Compression:

Stored size: 621 Bytes

Contents

module Ruby2JS
  class Converter

    # (dstr
    #   (str 'a')
    #   (...))

    # (dsym
    #   (str 'a')
    #   (...))

    handle :dstr, :dsym do |*children|
      children.map! do |child| 
        if child.type == :begin and child.children.length == 1
          child = child.children.first
        end

        if child.type == :send
          op_index = operator_index child.children[1]
          if op_index >= operator_index(:+)
            group child
          else
            parse child
          end
        else
          parse child
        end
      end

      children.join(' + ')
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby2js-1.15.1 lib/ruby2js/converter/dstr.rb
ruby2js-1.15.0 lib/ruby2js/converter/dstr.rb
ruby2js-1.14.1 lib/ruby2js/converter/dstr.rb
ruby2js-1.14.0 lib/ruby2js/converter/dstr.rb
ruby2js-1.13.1 lib/ruby2js/converter/dstr.rb
ruby2js-1.13.0 lib/ruby2js/converter/dstr.rb
ruby2js-1.12.2 lib/ruby2js/converter/dstr.rb
ruby2js-1.12.1 lib/ruby2js/converter/dstr.rb
ruby2js-1.12.0 lib/ruby2js/converter/dstr.rb
ruby2js-1.11.1 lib/ruby2js/converter/dstr.rb
ruby2js-1.11.0 lib/ruby2js/converter/dstr.rb
ruby2js-1.10.0 lib/ruby2js/converter/dstr.rb
ruby2js-1.9.3 lib/ruby2js/converter/dstr.rb
ruby2js-1.9.2 lib/ruby2js/converter/dstr.rb
ruby2js-1.9.1 lib/ruby2js/converter/dstr.rb
ruby2js-1.9.0 lib/ruby2js/converter/dstr.rb