Class: Yoda::Model::FunctionSignatures::TypeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/model/function_signatures/type_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parameters, tag_list) ⇒ TypeBuilder

Returns a new instance of TypeBuilder.

Parameters:



14
15
16
17
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 14

def initialize(parameters, tag_list)
  @parameters = parameters
  @tag_list = tag_list
end

Instance Attribute Details

#parametersParameterList (readonly)

Returns:



6
7
8
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 6

def parameters
  @parameters
end

#tag_listArray<Store::Objects::Tag> (readonly)

Returns:



9
10
11
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 9

def tag_list
  @tag_list
end

Instance Method Details

#typeTypes::FunctionType

Returns:



20
21
22
23
24
25
26
27
28
29
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 20

def type
  @type ||= begin
    if !type_tags.empty?
      parsed_type = parse_type_tag(type_tags.first)
      parsed_type.is_a?(Types::FunctionType) ? parsed_type : Types::FunctionType.new(return_type: parsed_type)
    else
      Types::FunctionType.new(return_type: return_types.first || Types::UnknownType.new('nodoc'), **parameter_options)
    end
  end
end

#type_of(param) ⇒ Types::Base

Parameters:

  • param (String)

Returns:



33
34
35
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 33

def type_of(param)
  param_type_table[param] || Types::UnknownType.new('nodoc')
end