Class: Xumlidot::Types::Superklass

Inherits:
Constant
  • Object
show all
Defined in:
lib/xumlidot/types/superklass.rb

Direct Known Subclasses

InheritedModule

Instance Attribute Summary

Attributes inherited from Constant

#name, #namespace, #reference

Instance Method Summary collapse

Methods inherited from Constant

#empty?, #to_s

Constructor Details

#initialize(name, namespace = nil) ⇒ Superklass

Returns a new instance of Superklass.



8
9
10
11
# File 'lib/xumlidot/types/superklass.rb', line 8

def initialize(name, namespace = nil)
  super
  @has_root = false
end

Instance Method Details

#<<(constant) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/xumlidot/types/superklass.rb', line 13

def <<(constant)
  if constant == '::'
    @has_root = true
    return
  end

  @namespace << constant unless @name.nil?
  @name ||= constant
end

#to_klassObject

Create a klass from the superclass for adding to the list of constants.



25
26
27
28
29
# File 'lib/xumlidot/types/superklass.rb', line 25

def to_klass
  definition = KlassDefinition.new
  definition.name << ::Xumlidot::Types::Constant.new(@name, @namespace)
  Klass.new(definition)
end