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.



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

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.



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

def extended_interfaces
  @extended_interfaces
end

#extended_modulesObject (readonly)

Returns the value of attribute extended_modules.



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

def extended_modules
  @extended_modules
end

#included_interfacesObject (readonly)

Returns the value of attribute included_interfaces.



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

def included_interfaces
  @included_interfaces
end

#included_modulesObject (readonly)

Returns the value of attribute included_modules.



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

def included_modules
  @included_modules
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end

#prepended_modulesObject (readonly)

Returns the value of attribute prepended_modules.



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

def prepended_modules
  @prepended_modules
end

#self_typesObject (readonly)

Returns the value of attribute self_types.



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

def self_types
  @self_types
end

#super_classObject (readonly)

Returns the value of attribute super_class.



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

def super_class
  @super_class
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



5
6
7
# File 'lib/rbs/definition_builder/ancestor_builder.rb', line 5

def type_name
  @type_name
end

Class Method Details

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



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

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



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

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



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

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



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

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



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

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



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

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

#each_extended_module(&block) ⇒ Object



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

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

#each_included_interface(&block) ⇒ Object



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

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

#each_included_module(&block) ⇒ Object



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

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

#each_prepended_module(&block) ⇒ Object



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

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

#each_self_type(&block) ⇒ Object



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

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