Class: RBS::DefinitionBuilder::AncestorBuilder::OneAncestors

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/definition_builder/ancestor_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:, included_interfaces:, prepended_modules:, extended_modules:, extended_interfaces:) ⇒ OneAncestors

Returns a new instance of OneAncestors.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 17

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

Instance Attribute Details

#extended_interfacesObject (readonly)

Returns the value of attribute extended_interfaces.



15
16
17
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 15

def extended_interfaces
  @extended_interfaces
end

#extended_modulesObject (readonly)

Returns the value of attribute extended_modules.



14
15
16
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 14

def extended_modules
  @extended_modules
end

#included_interfacesObject (readonly)

Returns the value of attribute included_interfaces.



12
13
14
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 12

def included_interfaces
  @included_interfaces
end

#included_modulesObject (readonly)

Returns the value of attribute included_modules.



11
12
13
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 11

def included_modules
  @included_modules
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 8

def params
  @params
end

#prepended_modulesObject (readonly)

Returns the value of attribute prepended_modules.



13
14
15
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 13

def prepended_modules
  @prepended_modules
end

#self_typesObject (readonly)

Returns the value of attribute self_types.



10
11
12
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 10

def self_types
  @self_types
end

#super_classObject (readonly)

Returns the value of attribute super_class.



9
10
11
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 9

def super_class
  @super_class
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



7
8
9
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 7

def type_name
  @type_name
end

Class Method Details

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



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 94

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: [],
    included_interfaces: [],
    prepended_modules: [],
    extended_modules: nil,
    extended_interfaces: nil
  )
end

.interface(type_name:, params:) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 136

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

.module_instance(type_name:, params:) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 122

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

.singleton(type_name:, super_class:) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 108

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

Instance Method Details

#each_ancestor(&block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 29

def each_ancestor(&block)
  if block
    if s = super_class
      yield s
    end

    each_self_type(&block)
    each_included_module(&block)
    each_included_interface(&block)
    each_prepended_module(&block)
    each_extended_module(&block)
    each_extended_interface(&block)
  else
    enum_for :each_ancestor
  end
end

#each_extended_interface(&block) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 86

def each_extended_interface(&block)
  if block
    extended_interfaces&.each(&block)
  else
    enum_for :each_extended_interface
  end
end

#each_extended_module(&block) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 78

def each_extended_module(&block)
  if block
    extended_modules&.each(&block)
  else
    enum_for :each_extended_module
  end
end

#each_included_interface(&block) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 62

def each_included_interface(&block)
  if block
    included_interfaces&.each(&block)
  else
    enum_for :each_included_interface
  end
end

#each_included_module(&block) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 54

def each_included_module(&block)
  if block
    included_modules&.each(&block)
  else
    enum_for :each_included_module
  end
end

#each_prepended_module(&block) ⇒ Object



70
71
72
73
74
75
76
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 70

def each_prepended_module(&block)
  if block
    prepended_modules&.each(&block)
  else
    enum_for :each_prepended_module
  end
end

#each_self_type(&block) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 46

def each_self_type(&block)
  if block
    self_types&.each(&block)
  else
    enum_for :each_self_type
  end
end