Sha256: 56e8fd30134e9ee1f45998304277f9c0d09fd15f382665c5318bf3601692f7cc

Contents?: true

Size: 874 Bytes

Versions: 21

Compression:

Stored size: 874 Bytes

Contents

class Code
  class Node
    class Dictionnary < Node
      class KeyValue < Node
        def initialize(parsed)
          if parsed.key?(:statement)
            @key = Node::Statement.new(parsed.delete(:statement))
          elsif parsed.key?(:name)
            @key = Node::String.new([{ text: parsed.delete(:name) }])
          end

          @value = Node::Code.new(parsed.delete(:value))
        end

        def evaluate(**args)
          [@key.evaluate(**args), @value.evaluate(**args)]
        end
      end

      def initialize(parsed)
        parsed = [] if parsed == ""
        @key_values =
          parsed.map { |key_value| Node::Dictionnary::KeyValue.new(key_value) }
      end

      def evaluate(**args)
        ::Code::Object::Dictionnary.new(
          @key_values.map { |key_value| key_value.evaluate(**args) }.to_h
        )
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

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