Class: RBS::Dynamic::Builder::Class

Inherits:
Base
  • Object
show all
Defined in:
lib/rbs/dynamic/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Class

Returns a new instance of Class.



165
166
167
168
# File 'lib/rbs/dynamic/builder.rb', line 165

def initialize(klass)
  super()
  @klass = klass
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



163
164
165
# File 'lib/rbs/dynamic/builder.rb', line 163

def klass
  @klass
end

Instance Method Details

#buildObject



170
171
172
173
174
175
176
177
178
179
180
# File 'lib/rbs/dynamic/builder.rb', line 170

def build
  RBS::AST::Declarations::Class.new(
    name: klass.name,
    type_params: [],
    super_class: build_super_class,
    members: build_members,
    location: nil,
    annotations: [],
    comment: nil
  )
end

#build_super_classObject



182
183
184
185
186
187
188
# File 'lib/rbs/dynamic/builder.rb', line 182

def build_super_class
  ::RBS::AST::Declarations::Class::Super.new(
    name: klass.superclass.name,
    args: [],
    location: nil
  ) unless klass.superclass&.name.nil? || Object == klass.superclass
end