Class: Dry::Types::Printer Private
- Inherits:
-
Object
- Object
- Dry::Types::Printer
- Defined in:
- lib/dry/types/tuple.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #visit_tuple(tuple) ⇒ Object private
Instance Method Details
#visit_tuple(tuple) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/dry/types/tuple.rb', line 190 def visit_tuple(tuple) = tuple..dup size = tuple.fixed_types.size size += 1 unless tuple.rest_type.nil? types = .delete(:types_index) (, tuple.) do |opts| header = "Tuple<" rest = visit(types.default) { "*: #{_1}" } if types.default if size.zero? yield "#{header}>#{opts}" else yield header.dup << ( types.flat_map do |pos, pos_types| Kernel.Array(pos_types).map do |pos_type| visit(pos_type) { "#{pos}: #{_1}" } end end << rest ).compact.join(", ") << ">#{opts}" end end end |