Class: Yoda::Typing::Types::AssociativeArray
- Defined in:
- lib/yoda/typing/types/associative_array.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(contents:) ⇒ AssociativeArray
constructor
A new instance of AssociativeArray.
- #to_expression ⇒ Object
- #to_type_string ⇒ Object
- #visilibity ⇒ Object
Methods inherited from Base
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_expression ⇒ Object
13 14 15 |
# File 'lib/yoda/typing/types/associative_array.rb', line 13 def to_expression contents.transform_values(&:to_expression) end |
#to_type_string ⇒ Object
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 |
#visilibity ⇒ Object
17 18 19 |
# File 'lib/yoda/typing/types/associative_array.rb', line 17 def visilibity @self_call ? [:private, :public, :protected] : [:public] end |