Sha256: 869ddc23c8a08eea0621209058bc2bf1c8b5cafaee2d02202619160efdbf119b

Contents?: true

Size: 512 Bytes

Versions: 21

Compression:

Stored size: 512 Bytes

Contents

class Code
  class Node
    class ChainedCall < Node
      def initialize(parsed)
        @first = Node::Statement.new(parsed.delete(:first))
        @others =
          parsed
            .delete(:others)
            .map { |operator| Node::Statement.new(operator) }

        super(parsed)
      end

      def evaluate(**args)
        first = @first.evaluate(**args)

        @others.reduce(first) do |acc, element|
          element.evaluate(**args.merge(object: acc))
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

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