Sha256: 929fcc0661ab92dcb03fd5563c0d7fe90198d51236a7a32da1c2fee8623829bf

Contents?: true

Size: 690 Bytes

Versions: 92

Compression:

Stored size: 690 Bytes

Contents

require 'ruby2js'

module Ruby2JS
  module Filter
    module Return
      include SEXP

      EXPRESSIONS = [ :array, :float, :hash, :if, :int, :lvar, :nil, :send ]

      def on_block(node)
        children = process_all(node.children)

        children[-1] = s(:nil) if children.last == nil

        node.updated nil, [*node.children[0..1],
          s(:autoreturn, *children[2..-1])]
      end

      def on_def(node)
        children = process_all(node.children[1..-1])

        children[-1] = s(:nil) if children.last == nil

        node.updated nil, [node.children[0], children.first,
          s(:autoreturn, *children[1..-1])]
      end
    end

    DEFAULTS.push Return
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
ruby2js-3.3.6 lib/ruby2js/filter/return.rb
ruby2js-3.3.5 lib/ruby2js/filter/return.rb
ruby2js-3.3.4 lib/ruby2js/filter/return.rb
ruby2js-3.3.3 lib/ruby2js/filter/return.rb
ruby2js-3.3.2 lib/ruby2js/filter/return.rb
ruby2js-3.3.1 lib/ruby2js/filter/return.rb
ruby2js-3.3.0 lib/ruby2js/filter/return.rb
ruby2js-3.2.0 lib/ruby2js/filter/return.rb
ruby2js-3.1.2 lib/ruby2js/filter/return.rb
ruby2js-3.1.1 lib/ruby2js/filter/return.rb
ruby2js-3.1.0 lib/ruby2js/filter/return.rb
ruby2js-3.0.15 lib/ruby2js/filter/return.rb
ruby2js-3.0.14 lib/ruby2js/filter/return.rb
ruby2js-3.0.13 lib/ruby2js/filter/return.rb
ruby2js-3.0.12 lib/ruby2js/filter/return.rb
ruby2js-3.0.11 lib/ruby2js/filter/return.rb
ruby2js-3.0.10 lib/ruby2js/filter/return.rb
ruby2js-3.0.9 lib/ruby2js/filter/return.rb
ruby2js-3.0.8 lib/ruby2js/filter/return.rb
ruby2js-3.0.7 lib/ruby2js/filter/return.rb