Class: Yoda::Typing::Types::Method
- Defined in:
- lib/yoda/typing/types/method.rb
Instance Attribute Summary collapse
- #callee ⇒ Base readonly
- #method_name ⇒ String readonly
Instance Method Summary collapse
-
#initialize(callee, method_name, with_receiver: false) ⇒ Method
constructor
A new instance of Method.
- #to_expression(resolver) ⇒ Object
- #to_type_string ⇒ Object
- #visilibity ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(callee, method_name, with_receiver: false) ⇒ Method
14 15 16 17 |
# File 'lib/yoda/typing/types/method.rb', line 14 def initialize(callee, method_name, with_receiver: false) @callee = callee @method_name = method_name end |
Instance Attribute Details
#callee ⇒ Base (readonly)
6 7 8 |
# File 'lib/yoda/typing/types/method.rb', line 6 def callee @callee end |
#method_name ⇒ String (readonly)
9 10 11 |
# File 'lib/yoda/typing/types/method.rb', line 9 def method_name @method_name end |
Instance Method Details
#to_expression(resolver) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/yoda/typing/types/method.rb', line 19 def to_expression(resolver) callee_type = to_expression(callee) values = callee_type.instanciate(resolver.registry) Model::TypeExpressions::UnionType.new( values.map do |value| value.methods(visibility: visibility).select { |func| func.name == method_name } end.flatten ) end |
#to_type_string ⇒ Object
33 34 35 |
# File 'lib/yoda/typing/types/method.rb', line 33 def to_type_string "#{callee.to_type_string}##{method_name}" end |
#visilibity ⇒ Object
29 30 31 |
# File 'lib/yoda/typing/types/method.rb', line 29 def visilibity @self_call ? [:private, :public, :protected] : [:public] end |