Class: Yoda::Model::FunctionSignatures::TypeBuilder
- Inherits:
-
Object
- Object
- Yoda::Model::FunctionSignatures::TypeBuilder
- Defined in:
- lib/yoda/model/function_signatures/type_builder.rb
Overview
TypeBuilder builds TypeExpression::FunctionType instance from YARD tags and parameter list.
Defined Under Namespace
Classes: TypeParser
Instance Attribute Summary collapse
- #parameters ⇒ ParameterList readonly
- #tag_list ⇒ Array<Store::Objects::Tag> readonly
Instance Method Summary collapse
-
#initialize(parameters, tag_list) ⇒ TypeBuilder
constructor
A new instance of TypeBuilder.
- #parameter_of(name) ⇒ TypeExpressions::FunctionType::Parameter
- #type ⇒ TypeExpressions::FunctionType
- #type_of(param) ⇒ TypeExpressions::Base
Constructor Details
#initialize(parameters, tag_list) ⇒ TypeBuilder
Returns a new instance of TypeBuilder.
15 16 17 18 |
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 15 def initialize(parameters, tag_list) @parameters = parameters @tag_list = tag_list end |
Instance Attribute Details
#parameters ⇒ ParameterList (readonly)
7 8 9 |
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 7 def parameters @parameters end |
#tag_list ⇒ Array<Store::Objects::Tag> (readonly)
10 11 12 |
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 10 def tag_list @tag_list end |
Instance Method Details
#parameter_of(name) ⇒ TypeExpressions::FunctionType::Parameter
40 41 42 |
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 40 def parameter_of(name) TypeExpressions::FunctionType::Parameter.new(name: name, type: type_of(name)) end |
#type ⇒ TypeExpressions::FunctionType
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 21 def type @type ||= begin if !.empty? parsed_type = parse_type_tag(.first) parsed_type.is_a?(TypeExpressions::FunctionType) ? parsed_type : TypeExpressions::FunctionType.new(return_type: parsed_type) else TypeExpressions::FunctionType.new(return_type: return_types.first || TypeExpressions::UnknownType.new('nodoc'), **) end end end |
#type_of(param) ⇒ TypeExpressions::Base
34 35 36 |
# File 'lib/yoda/model/function_signatures/type_builder.rb', line 34 def type_of(param) param_type_table[param] || TypeExpressions::UnknownType.new('nodoc') end |