Sha256: 2a0c72680831357df8f17cc22b067f51aadf4aefed738f6dc0f2e511c28c6996

Contents?: true

Size: 705 Bytes

Versions: 21

Compression:

Stored size: 705 Bytes

Contents

class Code
  class Object
    class RubyFunction < ::Code::Object::Function
      attr_reader :raw

      def initialize(raw)
        @raw = raw
      end

      private

      def call_function(args:, globals:)
        regular_arguments =
          args
            .select(&:regular?)
            .map(&:value)
            .map { |argument| ::Code::Ruby.from_code(argument) }

        keyword_arguments =
          args
            .select(&:keyword?)
            .map do |argument|
              [argument.name.to_sym, ::Code::Ruby.from_code(argument.value)]
            end
            .to_h

        ::Code::Ruby.to_code(raw.call(*regular_arguments, **keyword_arguments))
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
template-ruby-0.5.6 lib/code/object/ruby_function.rb
language-ruby-0.5.6 lib/code/object/ruby_function.rb
code-ruby-0.5.6 lib/code/object/ruby_function.rb
template-ruby-0.5.5 lib/code/object/ruby_function.rb
language-ruby-0.5.5 lib/code/object/ruby_function.rb
code-ruby-0.5.5 lib/code/object/ruby_function.rb
template-ruby-0.5.4 lib/code/object/ruby_function.rb
language-ruby-0.5.4 lib/code/object/ruby_function.rb
code-ruby-0.5.4 lib/code/object/ruby_function.rb
template-ruby-0.5.3 lib/code/object/ruby_function.rb
language-ruby-0.5.3 lib/code/object/ruby_function.rb
code-ruby-0.5.3 lib/code/object/ruby_function.rb
template-ruby-0.5.2 lib/code/object/ruby_function.rb
language-ruby-0.5.2 lib/code/object/ruby_function.rb
code-ruby-0.5.2 lib/code/object/ruby_function.rb
language-ruby-0.5.1 lib/code/object/ruby_function.rb
template-ruby-0.5.1 lib/code/object/ruby_function.rb
code-ruby-0.5.1 lib/code/object/ruby_function.rb
template-ruby-0.5.0 lib/code/object/ruby_function.rb
language-ruby-0.5.0 lib/code/object/ruby_function.rb