Sha256: 1ea590ad953ceeaa87f1cfc1f8e73290e92cfa75eda855ceddb30f2ee299ae0b

Contents?: true

Size: 539 Bytes

Versions: 7

Compression:

Stored size: 539 Bytes

Contents

module Ruby2JS
  class Converter

    # (cvasgn :@@a
    #   (int 1))

    handle :cvasgn do |var, expression=nil|
      multi_assign_declarations if @state == :statement

      prefix = es2020 ? '#$' : '_'

      if @class_name
        parse @class_name
        put var.to_s.sub('@@', ".#{prefix}")
      elsif @prototype
        put var.to_s.sub('@@', "this.#{prefix}")
      else
        put var.to_s.sub('@@', "this.constructor.#{prefix}")
      end

      if expression
        put " = "; parse expression
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby2js-3.3.6 lib/ruby2js/converter/cvasgn.rb
ruby2js-3.3.5 lib/ruby2js/converter/cvasgn.rb
ruby2js-3.3.4 lib/ruby2js/converter/cvasgn.rb
ruby2js-3.3.3 lib/ruby2js/converter/cvasgn.rb
ruby2js-3.3.2 lib/ruby2js/converter/cvasgn.rb
ruby2js-3.3.1 lib/ruby2js/converter/cvasgn.rb
ruby2js-3.3.0 lib/ruby2js/converter/cvasgn.rb