Class: TypeProf::Core::OverloadSet
- Inherits:
-
Object
- Object
- TypeProf::Core::OverloadSet
- Includes:
- Enumerable
- Defined in:
- lib/typeprof/core/graph/box.rb
Instance Method Summary collapse
- #each(&blk) ⇒ Object
- #first ⇒ Object
-
#initialize(method_types) ⇒ OverloadSet
constructor
A new instance of OverloadSet.
- #map(&blk) ⇒ Object
- #overloads_differ_at_top_level? ⇒ Boolean
-
#overloads_differ_in_args? ⇒ Boolean
lazy cache: combination(2) for all-pair comparison.
-
#partition_by_rest_positionals ⇒ Object
lazy cache: overloads split into fixed-arity ones and rest-positional ones.
- #size ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(method_types) ⇒ OverloadSet
Returns a new instance of OverloadSet.
124 125 126 |
# File 'lib/typeprof/core/graph/box.rb', line 124 def initialize(method_types) @method_types = method_types end |
Instance Method Details
#each(&blk) ⇒ Object
128 |
# File 'lib/typeprof/core/graph/box.rb', line 128 def each(&blk) = @method_types.each(&blk) |
#first ⇒ Object
130 |
# File 'lib/typeprof/core/graph/box.rb', line 130 def first = @method_types.first |
#map(&blk) ⇒ Object
129 |
# File 'lib/typeprof/core/graph/box.rb', line 129 def map(&blk) = @method_types.map(&blk) |
#overloads_differ_at_top_level? ⇒ Boolean
142 143 144 145 146 147 |
# File 'lib/typeprof/core/graph/box.rb', line 142 def overloads_differ_at_top_level? return @overloads_differ_at_top_level if defined?(@overloads_differ_at_top_level) @overloads_differ_at_top_level = !@method_types.combination(2).all? { |a, b| positionals_match_shallow?(a, b) && keywords_match_shallow?(a, b) } end |
#overloads_differ_in_args? ⇒ Boolean
lazy cache: combination(2) for all-pair comparison
135 136 137 138 139 140 |
# File 'lib/typeprof/core/graph/box.rb', line 135 def overloads_differ_in_args? return @overloads_differ_in_args if defined?(@overloads_differ_in_args) @overloads_differ_in_args = !@method_types.combination(2).all? { |a, b| positionals_match?(a, b) && keywords_match?(a, b) } end |
#partition_by_rest_positionals ⇒ Object
lazy cache: overloads split into fixed-arity ones and rest-positional ones
150 151 152 153 |
# File 'lib/typeprof/core/graph/box.rb', line 150 def partition_by_rest_positionals @partition_by_rest_positionals ||= @method_types.partition {|method_type| !method_type.rest_positionals } end |
#size ⇒ Object
131 |
# File 'lib/typeprof/core/graph/box.rb', line 131 def size = @method_types.size |
#to_a ⇒ Object
132 |
# File 'lib/typeprof/core/graph/box.rb', line 132 def to_a = @method_types |