Class: TypeProf::Core::TypeAliasEntity
- Inherits:
-
Object
- Object
- TypeProf::Core::TypeAliasEntity
- Defined in:
- lib/typeprof/core/env/type_alias_entity.rb
Instance Attribute Summary collapse
-
#decls ⇒ Object
readonly
Returns the value of attribute decls.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #add_decl(decl) ⇒ Object
- #exist? ⇒ Boolean
-
#initialize ⇒ TypeAliasEntity
constructor
A new instance of TypeAliasEntity.
- #remove_decl(decl) ⇒ Object
Constructor Details
#initialize ⇒ TypeAliasEntity
Returns a new instance of TypeAliasEntity.
3 4 5 6 |
# File 'lib/typeprof/core/env/type_alias_entity.rb', line 3 def initialize @decls = Set[] @type = nil end |
Instance Attribute Details
#decls ⇒ Object (readonly)
Returns the value of attribute decls.
8 9 10 |
# File 'lib/typeprof/core/env/type_alias_entity.rb', line 8 def decls @decls end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/typeprof/core/env/type_alias_entity.rb', line 8 def type @type end |
Instance Method Details
#add_decl(decl) ⇒ Object
14 15 16 17 18 |
# File 'lib/typeprof/core/env/type_alias_entity.rb', line 14 def add_decl(decl) @decls << decl @type = decl.type unless @type # TODO: report an error if there are duplicated declarations end |
#exist? ⇒ Boolean
10 11 12 |
# File 'lib/typeprof/core/env/type_alias_entity.rb', line 10 def exist? !@decls.empty? end |
#remove_decl(decl) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/typeprof/core/env/type_alias_entity.rb', line 20 def remove_decl(decl) @decls.delete(decl) || raise if @type == decl.type @type = @decls.empty? ? nil : @decls.to_a.first.type end end |