Class: Yoda::Typing::Types::AssociativeArray

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/typing/types/associative_array.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#reference?

Constructor Details

#initialize(contents:) ⇒ AssociativeArray



9
10
11
# File 'lib/yoda/typing/types/associative_array.rb', line 9

def initialize(contents:)
  @contents = contents
end

Instance Attribute Details

#contents::Hash{ String, Symbol => Base } (readonly)



6
7
8
# File 'lib/yoda/typing/types/associative_array.rb', line 6

def contents
  @contents
end

Instance Method Details

#to_expressionObject



13
14
15
# File 'lib/yoda/typing/types/associative_array.rb', line 13

def to_expression
  contents.transform_values(&:to_expression)
end

#to_type_stringObject



21
22
23
24
# File 'lib/yoda/typing/types/associative_array.rb', line 21

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

#visilibityObject



17
18
19
# File 'lib/yoda/typing/types/associative_array.rb', line 17

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