Sha256: 9791eb1df34b08d0444cc7594e68f5c0e73a34ec643a4cb98f6e9eecab38280b
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module RaaP module Value class Intersection < BasicObject def initialize(type, size: 3) @type = type.is_a?(::String) ? RBS.parse_type(type) : type unless @type.instance_of?(::RBS::Types::Intersection) ::Kernel.raise ::TypeError, "not an intersection type: #{@type}" end @children = @type.types.map { |t| Type.new(t).pick(size:) } @size = size end def inspect "#<intersection @type.to_s=#{@type.to_s.inspect} @size=#{@size.inspect}>" end def class Intersection end def method_missing(name, *args, **kwargs, &block) if respond_to?(name) @children.each do |child| if BindCall.respond_to?(child, name) return child.__send__(name, *args, **kwargs, &block) end end ::Kernel.raise else super end end def respond_to?(name, include_all = false) @children.any? do |child| if BindCall.instance_of?(child, ::BasicObject) BindCall.respond_to?(child, name, include_all) else child.respond_to?(name, include_all) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
raap-0.4.0 | lib/raap/value/intersection.rb |