Class: Solargraph::ComplexType::UniqueType
- Inherits:
-
Object
- Object
- Solargraph::ComplexType::UniqueType
- Includes:
- TypeMethods
- Defined in:
- lib/solargraph/complex_type/unique_type.rb
Overview
An individual type signature. A complex type can consist of multiple unique types.
Instance Attribute Summary
Attributes included from TypeMethods
#name, #substring, #subtypes, #tag
Instance Method Summary collapse
-
#initialize(name, substring = '') ⇒ UniqueType
constructor
Create a UniqueType with the specified name and an optional substring.
- #to_s ⇒ Object
Methods included from TypeMethods
#==, #defined?, #duck_type?, #fixed_parameters?, #hash_parameters?, #key_types, #list_parameters?, #namespace, #nil_type?, #parameters?, #qualify, #scope, #undefined?, #value_types, #void?
Constructor Details
#initialize(name, substring = '') ⇒ UniqueType
Create a UniqueType with the specified name and an optional substring. The substring is the parameter section of a parametrized type, e.g., for the type ‘Array<String>`, the name is `Array` and the substring is `<String>`.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/solargraph/complex_type/unique_type.rb', line 16 def initialize name, substring = '' @name = name @substring = substring @tag = name + substring @key_types = [] @subtypes = [] return unless parameters? subs = ComplexType.parse(substring[1..-2], partial: true) if hash_parameters? raise ComplexTypeError, "Bad hash type" unless !subs.is_a?(ComplexType) and subs.length == 2 and !subs[0].is_a?(ComplexType) and !subs[1].is_a?(ComplexType) @key_types.concat subs[0] @subtypes.concat subs[1] else @subtypes.concat subs end end |
Instance Method Details
#to_s ⇒ Object
33 34 35 |
# File 'lib/solargraph/complex_type/unique_type.rb', line 33 def to_s tag end |