Class: Yadriggy::MethodType
Overview
Type of methods.
Instance Method Summary collapse
-
#initialize(method_def = nil, param_type_array, result_type) ⇒ MethodType
constructor
A new instance of MethodType.
-
#method_def ⇒ Parameters
The method definition.
-
#name ⇒ String
Obtains the name of this type.
-
#params ⇒ Array<Type>|DynType
Gets an array of the parameter types.
-
#result ⇒ ResultType
The result type.
-
#result_type ⇒ Type
The result type.
Methods inherited from Type
#!=, #copy, #eql?, error_found!, #exact_type, #has_role?, role, #supertype
Constructor Details
#initialize(method_def = nil, param_type_array, result_type) ⇒ MethodType
Returns a new instance of MethodType.
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/yadriggy/type.rb', line 479 def initialize(method_def=nil, param_type_array, result_type) @param_types = if param_type_array.is_a?(Array) param_type_array.map do |t| t.is_a?(Type) ? t : RubyClass[t] end else param_type_array end @result_type = if result_type.is_a?(Type) result_type else RubyClass[result_type] end @method_def = method_def end |
Instance Method Details
#method_def ⇒ Parameters
Returns the method definition.
503 |
# File 'lib/yadriggy/type.rb', line 503 def method_def() @method_def end |
#name ⇒ String
Obtains the name of this type.
535 536 537 538 539 540 541 542 543 544 |
# File 'lib/yadriggy/type.rb', line 535 def name name = '' if @param_types.is_a?(Array) name << '(' << @param_types.map{|e| e.name }.join(',') << ')' else name << @param_types.name end name << '->' << @result_type.name name end |
#params ⇒ Array<Type>|DynType
Gets an array of the parameter types.
497 |
# File 'lib/yadriggy/type.rb', line 497 def params() @param_types end |
#result ⇒ ResultType
Returns the result type. Note that a ResultType object is always returned.
529 530 531 |
# File 'lib/yadriggy/type.rb', line 529 def result() ResultType.new(@result_type, @method_def) end |
#result_type ⇒ Type
Returns the result type.
500 |
# File 'lib/yadriggy/type.rb', line 500 def result_type() @result_type end |