Class: RBS::DefinitionBuilder::OneAncestors

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/definition_builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name:, params:, super_class:, self_types:, included_modules:, prepended_modules:, extended_modules:) ⇒ OneAncestors

Returns a new instance of OneAncestors.



28
29
30
31
32
33
34
35
36
# File 'lib/rbs/definition_builder.rb', line 28

def initialize(type_name:, params:, super_class:, self_types:, included_modules:, prepended_modules:, extended_modules:)
  @type_name = type_name
  @params = params
  @super_class = super_class
  @self_types = self_types
  @included_modules = included_modules
  @prepended_modules = prepended_modules
  @extended_modules = extended_modules
end

Instance Attribute Details

#extended_modulesObject (readonly)

Returns the value of attribute extended_modules.



26
27
28
# File 'lib/rbs/definition_builder.rb', line 26

def extended_modules
  @extended_modules
end

#included_modulesObject (readonly)

Returns the value of attribute included_modules.



24
25
26
# File 'lib/rbs/definition_builder.rb', line 24

def included_modules
  @included_modules
end

#paramsObject (readonly)

Returns the value of attribute params.



21
22
23
# File 'lib/rbs/definition_builder.rb', line 21

def params
  @params
end

#prepended_modulesObject (readonly)

Returns the value of attribute prepended_modules.



25
26
27
# File 'lib/rbs/definition_builder.rb', line 25

def prepended_modules
  @prepended_modules
end

#self_typesObject (readonly)

Returns the value of attribute self_types.



23
24
25
# File 'lib/rbs/definition_builder.rb', line 23

def self_types
  @self_types
end

#super_classObject (readonly)

Returns the value of attribute super_class.



22
23
24
# File 'lib/rbs/definition_builder.rb', line 22

def super_class
  @super_class
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



20
21
22
# File 'lib/rbs/definition_builder.rb', line 20

def type_name
  @type_name
end

Class Method Details

.class_instance(type_name:, params:, super_class:) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rbs/definition_builder.rb', line 50

def self.class_instance(type_name:, params:, super_class:)
  new(
    type_name: type_name,
    params: params,
    super_class: super_class,
    self_types: nil,
    included_modules: [],
    prepended_modules: [],
    extended_modules: nil
  )
end

.module_instance(type_name:, params:) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rbs/definition_builder.rb', line 74

def self.module_instance(type_name:, params:)
  new(
    type_name: type_name,
    params: params,
    self_types: [],
    included_modules: [],
    prepended_modules: [],
    super_class: nil,
    extended_modules: nil
  )
end

.singleton(type_name:, super_class:) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rbs/definition_builder.rb', line 62

def self.singleton(type_name:, super_class:)
  new(
    type_name: type_name,
    params: nil,
    super_class: super_class,
    self_types: nil,
    included_modules: nil,
    prepended_modules: nil,
    extended_modules: []
  )
end

Instance Method Details

#each_ancestor(&block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rbs/definition_builder.rb', line 38

def each_ancestor(&block)
  if block_given?
    yield super_class if super_class
    self_types&.each(&block)
    included_modules&.each(&block)
    prepended_modules&.each(&block)
    extended_modules&.each(&block)
  else
    enum_for :each_ancestor
  end
end