Sha256: 030f053247c01f8079771d99f480c4b3d001b0ff5542453d90c24c7afbe20857

Contents?: true

Size: 683 Bytes

Versions: 4

Compression:

Stored size: 683 Bytes

Contents

module Yoda
  module Typing
    module Types
      class AssociativeArray < Base
        # @return [::Hash{ String, Symbol => Base }]
        attr_reader :contents

        # @param contents [::Hash{ String, Symbol => Base }]
        def initialize(contents:)
          @contents = contents
        end

        def to_expression
          contents.transform_values(&:to_expression)
        end

        def visilibity
          @self_call ? [:private, :public, :protected] : [:public]
        end

        def to_type_string
          inner = contents.map { |key, value| "#{key} => #{value.to_type_string}"}
          "{#{inner.join(', ')}}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoda-language-server-0.10.1 lib/yoda/typing/types/associative_array.rb
yoda-language-server-0.10.0 lib/yoda/typing/types/associative_array.rb
yoda-language-server-0.9.0 lib/yoda/typing/types/associative_array.rb
yoda-language-server-0.8.0 lib/yoda/typing/types/associative_array.rb